Hi all I am fairly new to Golang, I am writing a toy client and server app just to learn the libraries.
But I have the project folder:
philipherron@Philips-iMac {~/workspace/gospace/src/github.com/redbrain/station} $ echo $GOPATH
/Users/philipherron/workspace/gospace
I wanted to have 2 binaries:
But when I build I get:
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
I guess this is because it looks like I am making to mains in the same package.
So I tried creating a client and a server subdir and have the binaries in each of those, but I get:
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
I guess this is because I have the layout of:
$ tree
.
├── client
│ └── client.go
└── server
└── server.go
2 directories, 4 files
Not sure how to get around this, it would just be nice to have the same client and server in the same directory but maybe this is against how I should be doing things in go?
just rename your .go files. The compiler is trying to write to 'client' but 'client' is already taken by the directory.
$ tree
.
├── client
│ └── main.go
└── server
└── main.go
2 directories, 4 files
And/Or create a script that outputs them with a different name go build -o client client/main.go
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With