English 中文(简体)
我如何找到我的一揽子方案?
原标题:How do I make go find my package?
  • 时间:2012-05-15 12:35:15
  •  标签:
  • go

我在什么地方应该把我的包裹放在一边,以便用另一个包裹进口吗?

$ tree
.
├── main.go
└── src
    └── test.go

1 directory, 2 files

$ cat src/test.go 
package test

$ cat main.go 
package main

import "test"

$ go build main.go 
main.go:3:8: import "test": cannot find package
最佳回答

您。 • 在GOPATH/src/optional-what/foo/*.go的包裹 f源,并在编码中使用

import "optional-whatever/foo"

don t需要明确安装oo, go工具是一种建构工具,必要时将自动提供给你。

问题回答

有一些事情需要发生。 你们必须首先安装“测试”包:

$ export GOPATH=$(pwd)   # Assumes a bourne shell (not csh)
$ mkdir src/test
$ mv src/test.go src/test/test.go
$ mkdir pkg                 # go install will put packages here
$ go install test           # build the package and put it in $GOPATH/pkg
$ go build main.go

Note that it is not necessary to create pkg, as go install will do that for you. Once you ve installed the test package (generally a bad name, BTW) go build main.go should now give different errors (eg, "imported and not used")





相关问题
minimum work size of a goroutine [closed]

Does anyone know approximately what the minimum work size is needed in order for a goroutine to be beneficial (assuming that there are free cores for the work to be offloaded to)?

How do you get the terminal size in Go?

How do I get the terminal size in Go. In C it would look like this: struct ttysize ts; ioctl(0, TIOCGWINSZ, &ts); But how to i access TIOCGWINSZ in Go

What do you use to write Go [closed]

I know its a bit too early, but I ve been trying out Go (Google s Programming Language) and its kindof annoying to write code in gedit. So, my question: What do you use to experiment with Go?

Shared memory vs. Go channel communication

One of Go s slogans is Do not communicate by sharing memory; instead, share memory by communicating. I am wondering whether Go allows two different Go-compiled binaries running on the same machine to ...

Embedding instead of inheritance in Go

What is your opinion of this design decision? What advantages does it have and what disadvantages? Links: Embedding description

热门标签