doujue6196 2014-08-22 07:20
浏览 1764

使用GO语言从一个文件到另一个文件引用方法

I am learning Go language out of my own interest . I come from a typical OO programming . I am bit kind of stuck in using a method present in one file from another. So , D:\lib\pac\abc.go has a method called

func dosomething()
{
}

Now , I have created one more file called def.go in the same location In this file I am writing to function to call abc.go, but I am getting an exception called "undefined:dosomething" when I run this file using $ go test

func defFunc()
{
//call dosomething
}

Also both these files are in the same package. Any hint on this issue?

  • 写回答

2条回答 默认 最新

  • dongpao2871 2014-08-22 07:26
    关注

    Please read http://golang.org/doc/code.html and setup your GOPATH workspace correctly.

    Once you've done this there should be no issue as all files in a single Go package are able to access symbols declared in any file in the package.

    评论

报告相同问题?

悬赏问题

  • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
  • ¥15 基于52单片机的酒精浓度检测系统加继电器和sim800
  • ¥50 我撰写的python爬虫爬不了 要爬的网址有反爬机制
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥120 计算机网络的新校区组网设计
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据
  • ¥20 软件测试决策法疑问求解答