Skip to content

cmd/rebuild: rebuild -w is not the same as internal cmd/go action #23321

Closed
@ianlancetaylor

Description

@ianlancetaylor

In cmd/go/internal/work/buildid.go the method (*Builder).updateBuildID, when invoked with rewrite true, implies that it is the same as go tool buildid -w. But the code in the updateBuildID` method does this:

	newID := a.buildID[:strings.LastIndex(a.buildID, buildIDSeparator)] + buildIDSeparator + hashToString(hash)
	if len(newID) != len(a.buildID) {
		return fmt.Errorf("internal error: build ID length mismatch %q vs %q", a.buildID, newID)
	}

while the code in cmd/buildid/buildid.go does this:

	tail := id
	if i := strings.LastIndex(id, "."); i >= 0 {
		tail = tail[i+1:]
	}
	if len(tail) != len(hash)*2 {
		log.Fatalf("%s: cannot find %d-byte hash in id %s", file, len(hash), id)
	}
	newID := id[:len(id)-len(tail)] + fmt.Sprintf("%x", hash)

These should be the same.

I imagine that the code in cmd/go is considered correct and the code in cmd/buildid should change.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions