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

cmd/go: update -trimpath documentation #50402

Closed
hyangah opened this issue Dec 31, 2021 · 3 comments
Closed

cmd/go: update -trimpath documentation #50402

hyangah opened this issue Dec 31, 2021 · 3 comments
Labels
Documentation FrozenDueToAge help wanted NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@hyangah
Copy link
Contributor

hyangah commented Dec 31, 2021

What version of Go are you using (go version)?

$ go version
go1.18beta1

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/hakim/Library/Caches/go-build"
GOENV="/Users/hakim/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/hakim/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/hakim/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/Users/hakim/sdk/go1.18beta1"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/Users/hakim/sdk/go1.18beta1/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.18beta1"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/hakim/ww/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 -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/bw/6r6k9d113sv1_vvzk_1kfxbm001py5/T/go-build1609535835=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

Built the following program with -trimpath ( % go build -trimpath -o out )

--- go.mod ---
module work

go 1.17

require golang.org/x/mod v0.5.1

--- main.go ---
package main

import (
        "golang.org/x/mod/semver"
)

func main() {
        if semver.IsValid("1.0.0") {
                println("valid")
        }
}

What did you expect to see?

As described in go1.18beta1 help build, expected to see files from standard packages start with "go"

    -trimpath
            remove all file system paths from the resulting executable.
            Instead of absolute file system paths, the recorded file names
            will begin with either "go" (for the standard library),
            or a module path@version (when using modules),
            or a plain import path (when using GOPATH).

What did you see instead?

Files from standard libraries without "go" (plain import path + file base name)

% strings out | grep map.go
runtime/mbitmap.go
runtime/map.go

Description for packages from dependency modules seems correct.

% strings out | grep semver.go
golang.org/x/mod@v0.5.1/semver/semver.go

Maybe need to mention behavior for main module files explicitly.

% strings out | grep main.go  
work/main.go
@hyangah hyangah changed the title cmd/go: -trimpath documentation needs correction cmd/go: update -trimpath documentation Dec 31, 2021
@cagedmantis cagedmantis added NeedsFix The path to resolution is known, but the work has not been done. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. and removed NeedsFix The path to resolution is known, but the work has not been done. labels Jan 4, 2022
@cagedmantis cagedmantis added this to the Go1.18 milestone Jan 4, 2022
@cagedmantis
Copy link
Contributor

/cc @bcmills @matloob

@bcmills bcmills added help wanted NeedsFix The path to resolution is known, but the work has not been done. labels Jan 5, 2022
@gopherbot gopherbot removed the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jan 5, 2022
@gopherbot
Copy link

Change https://golang.org/cl/380078 mentions this issue: cmd/go: correct -trimpath docs for the standard library

@mpx
Copy link
Contributor

mpx commented Jan 22, 2022

Drafted a change. I haven't mentioned the "main" module since the behaviour depends on how it is built:

  • go build / go install will not have a version (like GOPATH)
  • go install full.path@latest will include the @ version.

Suggestions for concise terminology?

@golang golang locked and limited conversation to collaborators Jan 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Documentation FrozenDueToAge help wanted NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

5 participants