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

Open
hyangah opened this issue Dec 31, 2021 · 1 comment
Open

cmd/go: update -trimpath documentation #50402

hyangah opened this issue Dec 31, 2021 · 1 comment

Comments

@hyangah
Copy link
Contributor

@hyangah 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 this to the Go1.18 milestone Jan 4, 2022
@cagedmantis
Copy link
Contributor

@cagedmantis cagedmantis commented Jan 4, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants