Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with relative modules #597

Closed
ghost opened this issue Oct 12, 2022 · 5 comments
Closed

Problem with relative modules #597

ghost opened this issue Oct 12, 2022 · 5 comments
Labels
needs info Requires extra information to be solved

Comments

@ghost
Copy link

ghost commented Oct 12, 2022

What version of Garble and Go are you using?

$ garble version

mvdan.cc/garble v0.7.1

Build settings:
       -compiler gc
     CGO_ENABLED 1
          GOARCH amd64
            GOOS linux
         GOAMD64 v1

$ go version

go version go1.19 linux/amd64

What environment are you running Garble on?

go env GO111MODULE="" GOARCH="amd64" GOBIN="" GOCACHE="/root/.cache/go-build" GOENV="/root/.config/go/env" GOEXE="" GOEXPERIMENT="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOINSECURE="" GOMODCACHE="/root/go/pkg/mod" GONOPROXY="" GONOSUMDB="" GOOS="linux" GOPATH="/root/go" GOPRIVATE="" GOPROXY="https://proxy.golang.org,direct" GOROOT="/usr/local/go" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64" GOVCS="" GOVERSION="go1.19" GCCGO="gccgo" GOAMD64="v1" AR="ar" CC="gcc" CXX="g++" CGO_ENABLED="1" GOMOD="/root/my-app/apps/client/go.mod" GOWORK="" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build3719268885=/tmp/go-build -gno-record-gcc-switches"
$ go env

What did you do?

I used this command to build:

GOOS=linux /root/go/bin/garble -literals build -o client -trimpath -ldflags="-s -w" .

We have a structure which we shared a folder between multiple servers,
we have included the the package utils in each go.mod file using this line:

replace github.com/my-app/utils => ../../utils

also included in require section:

github.com/my-app/utils v0.0.0

What did you expect to see?

Garbled local dependency

What did you see instead?

# client --daemon
panic: runtime error: index out of range [3] with length 3

goroutine 1 [running]:
github.com/my-app/utils/bind.RepairOldBindFile({0xc00003b3e0, 0x1b})
	github.com/my-app/utils/bind/repair.go:35 +0xa45
wYOGbviW.Izz2Y6kH({0xda764e, 0xa})
	Gph_3PMr.go:1 +0x2e5
main.main()
	rm2AGtAy.go:1 +0x3b58
@mvdan
Copy link
Member

mvdan commented Oct 12, 2022

Is the replace directive the source of the problem here? Your code crashes, but that could be caused by a number of factors. Can you provide steps for us to reproduce the problem?

@mvdan mvdan added the needs info Requires extra information to be solved label Oct 12, 2022
@ghost
Copy link
Author

ghost commented Oct 12, 2022

The problem is not crashing, the crash is on purpose to show the panic trace.
The complete go package and file with the line is shown which is not garbled.

@mvdan
Copy link
Member

mvdan commented Oct 12, 2022

I see what you mean. Are you setting GOGARBLE properly? Because the default is to only obfuscate the current module. You might want GOGARBLE=github.com/your-org or GOGARBLE=*, see #598.

@ghost
Copy link
Author

ghost commented Oct 12, 2022

Let me try with GOGARBLE=github.com/your-org, if not working I will get back to you with a sample project.
Thanks.

@ghost
Copy link
Author

ghost commented Oct 12, 2022

The problem is fixed.
Thank you <3
@mvdan

@ghost ghost closed this as completed Oct 12, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs info Requires extra information to be solved
Development

No branches or pull requests

1 participant