Skip to content

net/netip: Prefix's MarshalText and String methods produce different values #50115

Closed
@capnspacehook

Description

@capnspacehook

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

$ go version
go version devel go1.18-766f89b5c6 Fri Dec 10 19:26:50 2021 +0000 linux/amd64

Does this issue reproduce with the latest release?

yes

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/capnspacehook/.cache/go-build"
GOENV="/home/capnspacehook/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/capnspacehook/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/capnspacehook/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/capnspacehook/Documents/git/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/capnspacehook/Documents/git/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="devel go1.18-766f89b5c6 Fri Dec 10 19:26:50 2021 +0000"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/capnspacehook/Documents/git/go/src/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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build3691310336=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Tested that Prefix's MarshalText and String methods produced the same values on valid addresses:

https://go.dev/play/p/5KqfR6YXCox?v=gotip

What did you expect to see?

true
"::ffff:192.168.140.255/8", "::ffff:192.168.140.255/8"

What did you see instead?

false
"::ffff:c0a8:8cff/8", "::ffff:192.168.140.255/8"

Again, I found this while working on #49367. Seems extremely similar to #50110.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions