dqch34769 2014-03-02 15:16
浏览 822
已采纳

是否可以在golang的同一文件夹中拥有两个软件包名称

I am a new person to golang.

Basically in node.js i used to organise my general functions like i will put in

lib/
  validation.js
  convert.js
  ..

Likewise i will organize. I need to do the same here..

I tried like

lib/
 validation.go ( package name validator )
 convert.go ( package name converter )

and in the main.go which is present at the root level of my src folder i import like "./lib" it works only if both package name is same else it throws error.

since i need separate names to call those function i cant give same packages coz of readability.

so basically i can create another folder in lib and with different Package name i can give. This is the option available or some other possibility is there.

Please suggest a good practice and optimum way.

  • 写回答

1条回答 默认 最新

  • doulian5857 2014-03-02 15:49
    关注

    Per the "Effective Go" documentation on golang.org:

    Another convention is that the package name is the base name of its source directory;

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 安装svn网络有问题怎么办
  • ¥15 Python爬取指定微博话题下的内容,保存为txt
  • ¥15 vue2登录调用后端接口如何实现
  • ¥65 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥15 latex怎么处理论文引理引用参考文献