Function in same package undefined

前端 未结 9 2048
太阳男子
太阳男子 2020-12-28 12:17

My project structure is like this.

packagetest/
    main.go
    lib.go

In main.go, I have this code.

package m         


        
9条回答
  •  不思量自难忘°
    2020-12-28 12:55

    On the golang.org webpage you can read about the build command that:

    If the arguments are a list of .go files, build treats them as a list of source files specifying a single package.

    So, go build main.go will treat main.go as a single package. Instead, you should use:

    go build
    

    to include all files in the folder.

提交回复
热议问题