大家好我对Golang相当新,我正在写一个玩具客户端和服务器应用程序只是为了学习库.
但我有项目文件夹:
philipherron@Philips-iMac {~/workspace/gospace/src/github.com/redbrain/station} $ echo $GOPATH
/Users/philipherron/workspace/gospace
Run Code Online (Sandbox Code Playgroud)
我想要2个二进制文件:
但是当我建立时,我得到:
philipherron@Philips-iMac {~/workspace/gospace/src/github.com/redbrain/station} $ go build github.com/redbrain/station/
# github.com/redbrain/station
./server.go:5: main redeclared in this block
previous declaration at ./client.go:5
Run Code Online (Sandbox Code Playgroud)
我想这是因为它看起来像是在同一个包中制作主电源.
所以我尝试创建一个客户端和一个服务器子目录,并在每个中都有二进制文件,但我得到:
philipherron@Philips-iMac {~/workspace/gospace/src/github.com/redbrain/station} $ go build github.com/redbrain/station/client
go install github.com/redbrain/station/client: build output "client" already exists and is a directory
Run Code Online (Sandbox Code Playgroud)
我猜这是因为我有以下布局:
$ tree
.
??? client
? ??? client.go
??? server
??? server.go
2 directories, 4 files
Run Code Online (Sandbox Code Playgroud)
不知道如何解决这个问题,在同一个目录中拥有相同的客户端和服务器会很好,但这可能与我应该如何做的事情相反?
只需重命名你的.go文件.编译器正在尝试写入'client',但目录已经占用'client'.
$ tree
.
??? client
? ??? main.go
??? server
??? main.go
2 directories, 4 files
Run Code Online (Sandbox Code Playgroud)
和/或创建一个脚本,用不同的名称输出它们 go build -o client client/main.go
归档时间: |
|
查看次数: |
4288 次 |
最近记录: |