Go: local import in non-local package

后端 未结 6 2082
孤街浪徒
孤街浪徒 2020-12-08 06:16

I have the following file structure:

.
├── bin
│   └── hello
├── pkg
└── src
    └── jacob.uk.com
        ├── greeting
        │   └── greeting.go
        └─         


        
6条回答
  •  南笙
    南笙 (楼主)
    2020-12-08 06:41

    Typing go build does not work with relative import paths; you must type go build main.go.

    go install does not work at all with relative import paths.

    It is documented at https://golang.org/cmd/go/#hdr-Relative_import_paths

    See

    • https://groups.google.com/forum/#!topic/golang-nuts/1XqcS8DuaNc/discussion
    • https://github.com/golang/go/issues/12502
    • https://github.com/golang/go/issues/3515#issuecomment-66066361

    for explanation.

提交回复
热议问题