How to import local packages in go?

后端 未结 4 400
[愿得一人]
[愿得一人] 2020-12-04 08:28

I am new to go and working on an example code that I want to localize.

In the original main.go import statement it was:

 import (
    &quo         


        
4条回答
  •  情话喂你
    2020-12-04 09:13

    Import paths are relative to your $GOPATH and $GOROOT environment variables. For example, with the following $GOPATH:

    GOPATH=/home/me/go
    

    Packages located in /home/me/go/src/lib/common and /home/me/go/src/lib/routers are imported respectively as:

    import (
        "lib/common"
        "lib/routers"
    )
    

提交回复
热议问题