Questions tagged [go-build]

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

60 questions
0
votes
1 answer

Building a static library with go build for Iphone simulator

I an building a c archive in my iOS project using following: GOOS=ios GOARCH=arm64 CGO_ENABLED=1 SDK=iphonesimulator CGO_CFLAGS="-fembed-bitcode" CC=pwd/clangwrap.sh go build -buildmode=c-archive -o libuplink.a Clangwrap.sh looks like…
joslinm
  • 7,845
  • 6
  • 49
  • 72
0
votes
1 answer

Building go tests from multiple packages into single file

Is there any way to build all the test files in a project located inside multiple packages into a single binary file? To build binary inside a single package, I could use go test -c. I need something like go test ./... -c,but this returns "cannot…
0
votes
1 answer

CGo doesn't compile C files

I have a really simple setup: A .go file (test.go) and a .c file (PMDK.c). I include the .c file in Go as follows: test.go: package main /* #include "PMDK.c" #cgo pkg-config: libpmem */ import "C" func main() { C.helloWorld() } When I run go…
manosgior
  • 49
  • 1
  • 6
0
votes
0 answers

How to statically link a Go executable against a Go compiled library on Windows?

Let's say that I have a package main which imports two other packages pkg1 and pkg2. pkg1 and pkg2 are not executable packages, they are library packages. Let's say that pkg1 and pkg2 are very large, are maintained on different repositories, and…
Victor Deleau
  • 875
  • 5
  • 17
0
votes
1 answer

build, buildmode=c does not give header file

I'm trying to build a Go package with the build flag -buildmode=c-shared. I'm expecting to get two files myfile.so and myfile.h. However, I'm only getting the .so file. Why is this and how can I fix it? The full command I am running is: go build -o…
GAP2002
  • 870
  • 4
  • 20
0
votes
1 answer

How to fix the go build error "reflect.typedmemclr not defined"?

I was trying to build a go binary for centOS in a docker container, It's giving the following error: # command-line-arguments github.com/ugorji/go/codec.rvSetDirect: relocation target reflect.typedmemclr not…
tourist
  • 506
  • 1
  • 6
  • 20
0
votes
1 answer

go build does not compile local changes into main

I am relatively new to go, and I am having some trouble with the go build system. GO Environment: (base) ngadre-mbp:github.com ngadre$ go version go version go1.14.5 darwin/amd64 (base) ngadre-mbp:github.com ngadre$ go…
RootPhoenix
  • 1,626
  • 1
  • 22
  • 40
0
votes
0 answers

is there any way to skip go build if the binary already the latest build

I wrote a simple bash script to go build then run the binary go build -o my-binary ./my-binary Is there any way to find that my binary already the latest build (no code change)?
iman tung
  • 63
  • 2
0
votes
0 answers

How to use go build to create a dynamic executable binary file that can run in docker container?

I use cross compile to compile a linux version binary on Mac. GOOS=linux GOARCH=amd64 go build Also tried the other command that I found on stack overflow. GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o targetBinary This binary can run in…
wzf1943
  • 121
  • 1
  • 9
0
votes
1 answer

import code from a separate package/folder

I have this directory layout: /baba biz.go # package baba /hello foo.go # package main biz.go looks like this: package baba func Foodd(z int) int { return z + 5 } and foo.go looks like this: package main import ( …
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
-1
votes
1 answer

Will go build pack unused external dependencies?

I have a lib module planned to be used across projects. It will depend on many other modules. But not all the projects will use functions provided by lib. I'm wondering if a project only depends on b/func B provided by lib, will it pack all the…
Luis.at.code
  • 299
  • 1
  • 3
  • 6
-1
votes
1 answer

Shall go build be run always from the folder of the main package if I want to build an executable?

I have a simple question on the build process in Go. I have a very simple app, the simplest possible, which is structured like this - myapp - main - main.go - go.mod with main.go being package main import "fmt" func main() { …
Picci
  • 16,775
  • 13
  • 70
  • 113
-2
votes
2 answers

Using a particular version for golang dependency module

I'm trying to build postfix-exporter code from the github link. It has a dependency on the go-systemd package as mentioned in go.mod file github.com/coreos/go-systemd/v22 v22.0.0. I see in the go.mod file , the mentioned version for the package is…
Learner
  • 1,544
  • 8
  • 29
  • 55
-2
votes
1 answer

Why open the go build's binary file with vim, I can see some source repositories info?

In windows, new go file: test.go package main import ( "fmt" ) func main() { fmt.Println("Hello World!") } Then run go build test.go and then vim test.exe. Search test.go, I can see many dir infos. Why it happens and how to hide the info?
Wilon
  • 117
  • 1
  • 6
-3
votes
1 answer

Why does go build succeed for a regexp.MustCompile parsing error?

It fails for go run or go test (compile then run), but not for go build (compile only). I would have thought MustCompile relates to compilation, not runtime. package main import ( "regexp" ) var someInvalidRegex =…
Henry Blyth
  • 1,700
  • 1
  • 15
  • 23
1 2 3
4