douzi8916 2016-10-23 02:44
浏览 466
已采纳

运行go install结果错误

I installed go on Windows. GOPATH is set to this:

    c:\go-workspace

I have file called login.go in this directory:

    C:\go-workspace\src\github.com\llnw\login

login.go contains this:

    package main
    func main() {
      fmt.Printf("login
")
    }

I tried the following to build:

    go build github.com/llnw/login/login

But I get this error:

    can't load package: package github.com/llnw/login/login: cannot find package "github.com/llnw/login/login" in any of:
    C:\Go\src\github.com\llnw\login\login (from $GOROOT)
    C:\go-workspace\src\github.com\llnw\login\login (from $GOPATH)

What am I doing wrong?

  • 写回答

1条回答 默认 最新

  • dongzhansong5785 2016-10-23 05:36
    关注

    From go build -h:

    usage: build [-o output] [-i] [build flags] [packages]
    
    Build compiles the packages named by the import paths,
    along with their dependencies, but it does not install the results.
    
    If the arguments to build are a list of .go files, build treats
    them as a list of source files specifying a single package.
    

    In your example, github.com/llnw/login/login looks neither like a package, nor a list of .go files. Probably you're looking for this:

    go build github.com/llnw/login
    

    Assuming that when you execute this command, the relative path github.com/llnw/login exists.

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

报告相同问题?

悬赏问题

  • ¥15 我想在一个软件里添加一个优惠弹窗,应该怎么写代码
  • ¥15 fluent的在模拟压强时使用希望得到一些建议
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 Web.config连不上数据库
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流