Coder Social home page Coder Social logo

Project Layout for multiple binaries about goxc HOT 8 CLOSED

 avatar commented on August 16, 2024
Project Layout for multiple binaries

from goxc.

Comments (8)

laher avatar laher commented on August 16, 2024

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 [email protected]
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

from goxc.

 avatar commented on August 16, 2024

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"
}

from goxc.

laher avatar laher commented on August 16, 2024

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 [email protected]
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)

from goxc.

 avatar commented on August 16, 2024

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/".

from goxc.

laher avatar laher commented on August 16, 2024

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 [email protected]
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)

from goxc.

 avatar commented on August 16, 2024

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

from goxc.

laher avatar laher commented on August 16, 2024

It will.

On Thu, May 12, 2016 at 12:17 AM, Dennis Günnewig [email protected]
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)

from goxc.

 avatar commented on August 16, 2024

Great! Thanks a lot. Now it works.

from goxc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.