Questions tagged [go-build]

For questions about compiling and building Go programs, including build commands and flags, build directives, conditional compilation, linking.

60 questions
3
votes
1 answer

How to compile all tests across a repo without executing them

I have a repo in which multiple teams contribute integration tests. All these tests are hidden behind //go:build integration flags, so if I want go to see or run them, I need to pass the -build integration flag to the test command. What I’m trying…
3
votes
2 answers

How to compile an amd64 binary that uses C on an M1 (arm64) Mac

My app compiles fine when GOARCH is set to arm64 (or is omitted). However, when I try to compile an amd64 binary (GOOS=darwin GOARCH=amd64 go build), I get the following error: package [mainPackage] imports [internalPackageThatUsesC]: build…
f-person
  • 331
  • 5
  • 16
3
votes
1 answer

Go get error while getting major version module dependency

I have an executable go module and i am trying to execute the below command go get github.com/saipraveen-a/number-manipulation/v2 and get this error: module github.com/saipraveen-a/number-manipulation@upgrade found (v1.0.1), but does not contain…
java_geek
  • 17,585
  • 30
  • 91
  • 113
3
votes
0 answers

/bin/sh: 1: go: not found when pushing to heroku

I'm trying to use React Frontend and Go Backend language. I have to Go installed locally and I can run commands like go run main.go or go build. But when I try to push to Heroku, I get the following error: $ rm -rf index && go build -o…
Ling ling
  • 51
  • 4
3
votes
1 answer

Importing packages from a local sub-directory

I'm new to go, so I hope this isn't perceived as dumb! My current folder structure looks similar to this In the models folder, I have person.go. package models //Person struct type Person struct { Name string Age int Gender…
Ali Khakpouri
  • 801
  • 8
  • 24
2
votes
1 answer

Golang Building Multi Platform Issue

Golang Building Multi Platform Issue I'm building a go application that I want to build for both Linux and Windows. For the Windows piece, I would like it to have the ability to install as a Windows Service. So in my app, I've included the following…
wymangr
  • 189
  • 3
  • 16
2
votes
1 answer

Error: "build flag -mod=vendor only valid when using modules" when building Go project

According to this document I need to add -mod=vendor to my build command to make use of my local vendor folder: By default, go commands like go build ignore the vendor directory when in module mode. The -mod=vendor flag (e.g., go build -mod=vendor)…
Nic
  • 12,220
  • 20
  • 77
  • 105
2
votes
9 answers

Golang installation

I just followed the installation guide for golang (ubuntu 16). I extracted the archive at /etc/usr I added env variable in /home/user/.profile I just tested a basic go build on the hello world code. I get the following error: The program 'go' is…
Itération 122442
  • 2,644
  • 2
  • 27
  • 73
2
votes
1 answer

Go build doesn't build custom libs

my working tree is like this: /opt/go/src/tb-to-composer/ ├── apis │   └── rtb.go ├── config.yaml ├── jsondef │   └── structures.go ├── LICENSE.md ├── README.md ├── tb-to-composer └── thingsToComposer.go when I do go build inside…
1
vote
0 answers

error obtaining VCS status: exit status 128 Use -buildvcs=false to disable VCS stamping

I am trying to build back-end of Grafana with "go run build.go build" command in the grafana directory in CMD. While building the back-end of Grafana, I get an error "error obtaining VCS status: exit status 128" and exit status 1 error obtaining VCS…
1
vote
0 answers

Is there a way to solve this error for pion/stun package ?? Error : //go:build comment without // +build comment

I'm trying to build a docker image of a video conferencing platform written in Go using the pion package. Below is the error I'm facing > [stage-0 6/6] RUN CGO_ENABLED=0 go build -o /bin/app ./cmd: #13 0.446…
1
vote
0 answers

How to build a 3rd-party executable file into a go executable?

I want to build chromium into a go executable file with go build, so that users can run the executable file without installing chromium. // my go code snippets ... import "github.com/chromedp/chromedp" opts := []chromedp.ExecAllocatorOption{ …
Chiamin
  • 77
  • 9
1
vote
2 answers

go build -mod=mod with no go.mod

If I run a command similar to the following: go build -mod=mod -o xyz.exe github.com/some/go/tool And I'm in a directory with a go.mod, I noticed that the go.mod will be updated with a reference to github.com/some/go/tool, and xyz.exe will be built.…
craig65535
  • 3,439
  • 1
  • 23
  • 49
1
vote
0 answers

Recompile only changed files in Go when using C++ lib

I am new to go. I use go-tdlib which in turn uses tdlib written in C++. First time the compilation took about 15-20 minutes, then I literally added one commented line to my Go main func (I just copypasted the example from go-tdlib, so it is just one…
Kalich
  • 87
  • 2
  • 6
1
vote
0 answers

Go build constraints to run if none set

I have many classes of test, which are marked with build constraints, e.g.: //go:build all || (!foo && !bar && !baz && quux) for the test class quux. This is okay, as far as it goes, but what I'd really rather have is constraints such that the…
YoureIt
  • 21
  • 1