doulang1945 2013-06-05 06:35
浏览 50
已采纳

具有多个文件的软件包如何在golang中工作?

This repo has 3 go files all begin with "package lumber". To use this package, I'm supposed to put this in my GOROOT and simply

import lumber

in my program. How do variables and types in this package connect with each other across multiple files? How does the go compiler know which file to begin reading first?

In case I want to read the package, where should I begin reading to understand the package? What exactly is the flow of things here?

  • 写回答

2条回答 默认 最新

  • doujun7161 2013-06-05 07:04
    关注

    No, you're not "supposed to put this in my GOROOT". You're supposed to execute

    $ go get github.com/jcelliott/lumber
    

    which will clone the repository into $GOPATH/src/github.com/jcelliott/lumber. Then you can use the package by importing it in your code as

    import "github.com/jcelliott/lumber"
    

    About the scoping rules: Declarations and scope

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥50 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?