Questions tagged [go-build]

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

60 questions
1
vote
0 answers

SWIG for Go - how do I set include pathes for c++ headers

I am trying to use a C++ library in a Go project with the help of SWIG. I have added a .swigcxx file with the necessary headers into my GO project directory, but they are not found by Go-GCC compiler as they are placed in other directories. I get…
1
vote
2 answers

GO Monorepo: List of Files that need to be re-built using go build

I have a monorepo setup for my go project. I would love it if I could find a way to use go build (or similar internal tool) to get a list of targets that need to be re-built. Here is an example of what I am looking for: ... ├── pkg //shared code…
t3r
  • 21
  • 3
1
vote
1 answer

Docker build : "go: go.mod file not found in current directory or any parent directory"

I am trying to build a Dockerfile of my Golang application which includes delve debugger - I want to debug my Golang application in Docker container. When I try to build my Docker I consistently go error below: Step 5/9 : RUN go build -gcflags…
Jia
  • 2,417
  • 1
  • 15
  • 25
1
vote
0 answers

Runing a compiled program on another macOS machine fails

When trying to run a simple compiled (with go build -o hello) "Hello world"-ish Go program on another macOS (M1 Air 2020), I get the following error: bash-3.2$ ./hello bash: ./hello: Operation not permitted The program runs fine on my machine…
f-person
  • 331
  • 5
  • 16
1
vote
1 answer

Golang compiling in a linux machine not connected to the internet

We have a CI/CD server that is not connected to the Internet due to company policy. I want to run Unit Tests in this server. I am allowed to WinScp files to it. To get it working, I thought I will FTP all the files from my source Windows machine…
Doyyan
  • 125
  • 1
  • 9
1
vote
1 answer

How to prevent from `go build` to update the latest version of modules

I am using an open source project called "yaegi" in a large project. I need to use older version of "yaegi": v.0.8.11, so I modified the go.mod file and replaced: github.com/traefik/yaegi v0.9.2 // indirect with github.com/containous/yaegi…
E235
  • 11,560
  • 24
  • 91
  • 141
1
vote
0 answers

Problem extracting object file while cross-compiling using 'go build'

I'm trying to create a go.o object file that I'll link using external linker. I followed the gopher-os procedure to extract object file. main.go: package main func main() { } Makefile: go.o: mkdir -p build GOARCH=386 GOOS=linux…
1
vote
0 answers

Can't compile Golang project that contains submodule

I have a Golang project with one git submodule like follows: Project go.mod main.go config.go go-blockchain/ (git Submodule) go.mod crypto/ encode.go (This has cgo code in it) crypto.go main.go When I run go build at the top level, I get…
Outerdev
  • 21
  • 3
1
vote
1 answer

Failed to instantiate provider - Custom Provider for Terraform Cloud - [fork/exec - exec format error]

I am trying to build an AWS Custom Provider for Terraform. The provider is at this repository: https://github.com/lyle-nel/terraform-provider-aws and I have followed all the instructions on the readme to create the provider binary. I have the…
1
vote
1 answer

Checking to make sure project compiles before pushing to version control remote

I have a script for TypeScript projects that makes sure my code compiles before I push it to the remote: simple_git_push_typescript(){ ( set -e top_level="$(git rev-parse --show-toplevel)" if [[ "$cm_ignore_tsc" != 'yes' ]]; then …
user12849275
1
vote
1 answer

How to cross-compile a Go package using github.com/mattn/go-sqlite3 for a Google Cloud VM?

This question is the same as go-sqlite3 compiler arguments for cross compile OSX to linux, but since that one doesn't have an answer I'll try asking again. I have a Go package which uses the github.com/mattn/go-sqlite3 SQLite3 driver, similar to the…
Kurt Peek
  • 52,165
  • 91
  • 301
  • 526
1
vote
1 answer

How to pass -ldflags to GAE build?

I have an HTTP service written in Go. Inside main.go I have a global version string. package main var version string Locally, I build using -ldflags "-X main.version=$VERSION where $VERSION is determined by the shell environment, like…
Andy Fusniak
  • 1,548
  • 1
  • 17
  • 28
1
vote
0 answers

Go - use of internal package [...] not allowed

I tried to clone and build the project from the stellar bridge-server github repository. After quite a lot of steps I am facing following errors: [ERROR] github.com\stellar\go\services\bridge\internal\handlers\main.go:8:2: use of internal package…
1
vote
1 answer

$GOPATH is set but go install does not work

I am trying to understand the go environment, but I can't seem to go install any package I git cloned locally. go install on the hello world example works fine. ~GOPATH/src/go-github(master ✔) go install -i…
sizzle
  • 2,883
  • 2
  • 13
  • 10
0
votes
1 answer

go build not working when used with workspaces

Below is the structure of my golang code, ├── go.work ├── moda │   ├── go.mod │   └── main.go ├── go.mod └── modb └── main.go The problem is I'm only able to build binary only for a single module. For building other modules it is only working…
ArigatoManga
  • 594
  • 5
  • 23