Skip to content
This repository has been archived by the owner on Jun 16, 2022. It is now read-only.

Project Layout for multiple binaries #105

Closed
ghost opened this issue May 11, 2016 · 8 comments
Closed

Project Layout for multiple binaries #105

ghost opened this issue May 11, 2016 · 8 comments

Comments

@ghost
Copy link

ghost commented May 11, 2016

Background

I would like to have two separate binaries compiled by goxc and packaged into a single archive:

  • Server (Mock for testing only)
  • Client

@laher Can you help me with that? I just trying to use go for my second small project. Thanks a lot in advance.

Problem

support for multiple binaries per project (goxc now searches subdirectories for 'main' packages)

I'm not able to build the project with goxc though there seems to be support for projects with multiple binaries.

The build fails with following error message:

[goxc:go-vet] 2016/05/11 12:59:10 Task go-vet succeeded
?       github.com/my-project/logging-platform-client/api     [no test files]
?       github.com/my-project/logging-platform-client/cli     [no test files]
# github.com/my-project/logging-platform-client/cmd
cmd/test-server.go:41: main redeclared in this block
        previous declaration at cmd/logging-platform-client.go:7
[goxc:go-test] 2016/05/11 12:59:10 'go' returned error: Wait error: exit status 2: # github.com/my-project/logging-platform-client/cmd
cmd/test-server.go:41: main redeclared in this block
        previous declaration at cmd/logging-platform-client.go:7
[goxc:go-test] 2016/05/11 12:59:10 Stopping after 'go-test' failed with error 'Wait error: exit status 2: # github.com/my-project/logging-platform-client/cmd
cmd/test-server.go:41: main redeclared in this block
        previous declaration at cmd/logging-platform-client.go:7'
[goxc] 2016/05/11 12:59:10 RunTasks error: Wait error: exit status 2: # github.com/my-project/logging-platform-client/cmd
cmd/test-server.go:41: main redeclared in this block
        previous declaration at cmd/logging-platform-client.go:7

Currently I structured the project the following way:

[git:master]% tree
.
├── api
│   └── log.go
├── cli
│   └── runner.go
├── cmd
│   ├── logging-platform-client.go
│   └── test-server.go
├── GoBuilds
│   └── logging-platform-client
│       └── 0.1.0
└── Makefile

Environment

  • goxc version: 0.17.1
  • goxc build date: empty
  • go version go1.6.2 linux/amd64
@laher
Copy link
Owner

laher commented May 11, 2016

Easy. Create 2 subfolders inside cmd:

cmd/logging-client/logging-platform-client.go
cmd/test-server/test-server.go

This is the usual way to lay out a Go project with multiple executables.
goxc supports this because go install ./cmd/... supports it too.

On Wed, May 11, 2016 at 11:05 PM, Dennis Günnewig notifications@github.com
wrote:

Background

I would like to have two separate binaries compiled by goxc and packaged
into a single archive:

  • Server (Mock for testing only)
  • Client

@laher https://github.com/laher Can you help me with that? I just
trying to use go for my second small project. Thanks a lot in advance.
Problem

support for multiple binaries per project (goxc now searches
subdirectories for 'main' packages)

I'm not able to build the project with goxc though there seems to be
support for projects with multiple binaries.

The build fails with following error message:

[goxc:go-vet] 2016/05/11 12:59:10 Task go-vet succeeded
? github.com/my-project/logging-platform-client/api [no test files]
? github.com/my-project/logging-platform-client/cli [no test files]

github.com/my-project/logging-platform-client/cmd

cmd/test-server.go:41 http://github.com/my-project/logging-platform-client/cmdcmd/test-server.go:41: main redeclared in this block
previous declaration at cmd/logging-platform-client.go:7
[goxc:go-test] 2016/05/11 12:59:10 'go' returned error: Wait error: exit status 2: # github.com/my-project/logging-platform-client/cmd
cmd/test-server.go:41 http://github.com/my-project/logging-platform-client/cmdcmd/test-server.go:41: main redeclared in this block
previous declaration at cmd/logging-platform-client.go:7
[goxc:go-test] 2016/05/11 12:59:10 Stopping after 'go-test' failed with error 'Wait error: exit status 2: # github.com/my-project/logging-platform-client/cmd
cmd/test-server.go:41 http://github.com/my-project/logging-platform-client/cmdcmd/test-server.go:41: main redeclared in this block
previous declaration at cmd/logging-platform-client.go:7'
[goxc] 2016/05/11 12:59:10 RunTasks error: Wait error: exit status 2: # github.com/my-project/logging-platform-client/cmd
cmd/test-server.go:41 http://github.com/my-project/logging-platform-client/cmdcmd/test-server.go:41: main redeclared in this block
previous declaration at cmd/logging-platform-client.go:7

Currently I structured the project the following way:

[git:master]% tree
.
├── api
│ └── log.go
├── cli
│ └── runner.go
├── cmd
│ ├── logging-platform-client.go
│ └── test-server.go
├── GoBuilds
│ └── logging-platform-client
│ └── 0.1.0
└── Makefile

Environment

  • goxc version: 0.17.1
  • goxc build date: empty
  • go version go1.6.2 linux/amd64


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#105

@ghost
Copy link
Author

ghost commented May 11, 2016

Thanks for the quick response, but that gives me a different error:

.
├── api
│   └── log.go
├── cli
│   └── runner.go
├── cmd
│   ├── logging-platform-client
│   │   └── logging-platform-client.go
│   └── test-server
│       └── test-server.go
├── GoBuilds
│   └── logging-platform-client
│       └── 0.1.0
└── Makefile
[goxc:go-vet] 2016/05/11 13:29:44 Task go-vet succeeded
?       github.com/my-project/logging-platform-client/api     [no test files]
?       github.com/my-project/logging-platform-client/cli     [no test files]
?       github.com/my-project/logging-platform-client/cmd/logging-platform-client     [no test files]
?       github.com/my-project/logging-platform-client/cmd/test-server [no test files]
[goxc:go-test] 2016/05/11 13:29:44 Task go-test succeeded
[goxc:go-install] 2016/05/11 13:29:44 Task go-install succeeded
[goxc:xc] 2016/05/11 13:29:44 Stopping after 'xc' failed with error 'The xc task will attempt to compile multiple binaries to the same path (/home/xgvndeg/.local/share/go/src/github.com/my-project/logging-platform-client/GoBuilds/logging-platform-client/0.1.0/logging-platform-client_0.1.0_linux_386). Please make sure {{.Os}} and {{.Arch}} variables are used in the OutPath. Currently the template is {{.Dest}}{{.PS}}{{.AppName}}{{.PS}}{{.Version}}{{.PS}}{{.AppName}}_{{.Version}}_{{.Os}}_{{.Arch}}{{.Ext}}'
[goxc] 2016/05/11 13:29:44 RunTasks error: The xc task will attempt to compile multiple binaries to the same path (/home/xgvndeg/.local/share/go/src/github.com/my-project/logging-platform-client/GoBuilds/logging-platform-client/0.1.0/logging-platform-client_0.1.0_linux_386). Please make sure {{.Os}} and {{.Arch}} variables are used in the OutPath. Currently the template is {{.Dest}}{{.PS}}{{.AppName}}{{.PS}}{{.Version}}{{.PS}}{{.AppName}}_{{.Version}}_{{.Os}}_{{.Arch}}{{.Ext}}

The config file

{
    "ArtifactsDest": "GoBuilds/",
    "OutPath": "{{.Dest}}{{.PS}}{{.AppName}}{{.PS}}{{.Version}}{{.PS}}{{.AppName}}_{{.Version}}_{{.Os}}_{{.Arch}}{{.Ext}}",
    "Tasks": [
        "default"
    ],
    "BuildConstraints": "linux windows darwin",
    "PackageVersion": "0.1.0",
    "TaskSettings": { },
    "ConfigVersion": "0.9"
}

@laher
Copy link
Owner

laher commented May 11, 2016

I think it's related to having the binaries inside your tree.
Could you try using "ArtifactsDest": "../GoBuilds/" and then move the
folder itself out of the way?
(it ought to still work anyway, but I don't commonly test for this scenario)

On Wed, May 11, 2016 at 11:33 PM, Dennis Günnewig notifications@github.com
wrote:

Thanks for the quick response, but that gives me a different error:

.
├── api
│ └── log.go
├── cli
│ └── runner.go
├── cmd
│ ├── logging-platform-client
│ │ └── logging-platform-client.go
│ └── test-server
│ └── test-server.go
├── GoBuilds
│ └── logging-platform-client
│ └── 0.1.0
└── Makefile

[goxc:go-vet] 2016/05/11 13:29:44 Task go-vet succeeded
? github.com/my-project/logging-platform-client/api [no test files]
? github.com/my-project/logging-platform-client/cli [no test files]
? github.com/my-project/logging-platform-client/cmd/logging-platform-client [no test files]
? github.com/my-project/logging-platform-client/cmd/test-server [no test files]
[goxc:go-test] 2016/05/11 13:29:44 Task go-test succeeded
[goxc:go-install] 2016/05/11 13:29:44 Task go-install succeeded
[goxc:xc] 2016/05/11 13:29:44 Stopping after 'xc' failed with error 'The xc task will attempt to compile multiple binaries to the same path (/home/xgvndeg/.local/share/go/src/github.com/my-project/logging-platform-client/GoBuilds/logging-platform-client/0.1.0/logging-platform-client_0.1.0_linux_386). Please make sure {{.Os}} and {{.Arch}} variables are used in the OutPath. Currently the template is {{.Dest}}{{.PS}}{{.AppName}}{{.PS}}{{.Version}}{{.PS}}{{.AppName}}{{.Version}}{{.Os}}{{.Arch}}{{.Ext}}'
[goxc] 2016/05/11 13:29:44 RunTasks error: The xc task will attempt to compile multiple binaries to the same path (/home/xgvndeg/.local/share/go/src/github.com/my-project/logging-platform-client/GoBuilds/logging-platform-client/0.1.0/logging-platform-client_0.1.0_linux_386). Please make sure {{.Os}} and {{.Arch}} variables are used in the OutPath. Currently the template is {{.Dest}}{{.PS}}{{.AppName}}{{.PS}}{{.Version}}{{.PS}}{{.AppName}}
{{.Version}}{{.Os}}{{.Arch}}{{.Ext}}

The config file

{
"ArtifactsDest": "GoBuilds/",
"OutPath": "{{.Dest}}{{.PS}}{{.AppName}}{{.PS}}{{.Version}}{{.PS}}{{.AppName}}{{.Version}}{{.Os}}_{{.Arch}}{{.Ext}}",
"Tasks": [
"default"
],
"BuildConstraints": "linux windows darwin",
"PackageVersion": "0.1.0",
"TaskSettings": { },
"ConfigVersion": "0.9"
}


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#105 (comment)

@ghost
Copy link
Author

ghost commented May 11, 2016

Mmmh... I tried...

  1. ... to remove the ArtifactsDest": "GoBuilds/"-setting and run goxc again
  2. ... to modify the setting to ArtifactsDest": "../GoBuilds/" and run goxc again

That didn't help. Here's the output of a goxc --verbose-run https://gist.github.com/dg-ratiodata/d5686cd66e6a382edf4a04e3d9a0c3af with "ArtifactsDest": "../GoBuilds/".

@laher
Copy link
Owner

laher commented May 11, 2016

OK. I see, it's the OutPath.
It should have the {{.ExeName}} in there somewhere otherwise both binaries
would end up with the same filename.
This should do it:

"OutPath": "{{.Dest}}{{.PS}}{{.AppName}}{{.PS}}{{.Version}}{{.PS}}{{.ExeName}}_{{.Version}}_{{.Os}}_{{.Arch}}{{.Ext}}",

On Thu, May 12, 2016 at 12:02 AM, Dennis Günnewig notifications@github.com
wrote:

Mmmh... I tried...

  1. ... to remove the ArtifactsDest": "GoBuilds/"-setting and run goxc
    again
  2. ... to modify the setting to ArtifactsDest": "../GoBuilds/" and run
    goxc again

That didn't help. Here's the output of a goxc --verbose-run
https://gist.github.com/dg-ratiodata/d5686cd66e6a382edf4a04e3d9a0c3af
with "ArtifactsDest": "../GoBuilds/".


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#105 (comment)

@ghost
Copy link
Author

ghost commented May 11, 2016

Ah. Ok. So it's not possible to put them into a single archive? That's what I assumed first.

@laher
Copy link
Owner

laher commented May 11, 2016

It will.

On Thu, May 12, 2016 at 12:17 AM, Dennis Günnewig notifications@github.com
wrote:

Ah. Ok. So it's not possible to put them into a single archive? That's
what I assumed first.


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#105 (comment)

@ghost
Copy link
Author

ghost commented May 11, 2016

Great! Thanks a lot. Now it works.

This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant