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

Use -trimpath for go1.13 #71

Closed
jonjohnsonjr opened this issue Aug 13, 2019 · 2 comments
Closed

Use -trimpath for go1.13 #71

jonjohnsonjr opened this issue Aug 13, 2019 · 2 comments
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@jonjohnsonjr
Copy link
Collaborator

Currently, the binary built by go build includes the file paths for the source files. For most people, GOPATH is in their home directory, so their username is embedded in the resulting binary, which makes reproducible images difficult for us.

In 1.13, we can use go build -trimpath to fix this.

See golang/go@7469564

@jonjohnsonjr jonjohnsonjr added enhancement New feature or request good first issue Good for newcomers labels Oct 22, 2019
@stanleynguyen
Copy link
Contributor

Hi @jonjohnsonjr Can I take this?

@jonjohnsonjr
Copy link
Collaborator Author

Definitely!

halvards added a commit that referenced this issue Nov 17, 2021
Enables programmatic control of whether `ko` adds the `-trimpath`
flag to `go build`.

The `-trimpath` flag removes file system paths from the resulting
binary. `ko` adds `-trimpath` by default as it aids in achieving
reproducible builds.

However, removing file system paths makes interactive debugging more
challenging, in particular in mapping source file locations in the
IDE to debug information in the binary.

If you set `Trimpath` to `false` to enable interactive debugging, you
probably also want to set `DisableOptimizations` to `true` to disable
compiler optimizations and inlining.

Reference for `-trimpath`:
https://pkg.go.dev/cmd/go#hdr-Compile_packages_and_dependencies

Resolves: #500
Related: #71, #78, GoogleContainerTools/skaffold#6843
halvards added a commit that referenced this issue Nov 17, 2021
Enables programmatic control of whether `ko` adds the `-trimpath`
flag to `go build`.

The `-trimpath` flag removes file system paths from the resulting
binary. `ko` adds `-trimpath` by default as it aids in achieving
reproducible builds.

However, removing file system paths makes interactive debugging more
challenging, in particular in mapping source file locations in the
IDE to debug information in the binary.

If you set `Trimpath` to `false` to enable interactive debugging, you
probably also want to set `DisableOptimizations` to `true` to disable
compiler optimizations and inlining.

Reference for `-trimpath`:
https://pkg.go.dev/cmd/go#hdr-Compile_packages_and_dependencies

Resolves: #500
Related: #71, #78, GoogleContainerTools/skaffold#6843
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants