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

fmt: Incorrect Hexadecimal Output for Custom Type Alias of uint8 Using fmt.Printf with %x #70153

Closed
t5w0rd opened this issue Nov 1, 2024 · 4 comments
Labels
WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.

Comments

@t5w0rd
Copy link

t5w0rd commented Nov 1, 2024

Go version

go version go1.23.2 darwin/arm64

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/t5w0rd/Library/Caches/go-build'
GOENV='/Users/t5w0rd/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/t5w0rd/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/t5w0rd/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/opt/homebrew/Cellar/go/1.23.2/libexec'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='local'
GOTOOLDIR='/opt/homebrew/Cellar/go/1.23.2/libexec/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.23.2'
GODEBUG=''
GOTELEMETRY='local'
GOTELEMETRYDIR='/Users/t5w0rd/Library/Application Support/go/telemetry'
GCCGO='gccgo'
GOARM64='v8.0'
AR='ar'
CC='cc'
CXX='c++'
CGO_ENABLED='1'
GOMOD='/Users/t5w0rd/proj/xmlschema/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/w9/ht8w67w93zz6p0p_3_rs3hg40000gn/T/go-build487759924=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

package main

import (
	"fmt"
	"proto" // Assume this is a valid import path
)

// type NodeProperty uint8  // defined in "proto"

type LocalNodeProperty uint8

func main() {
	var pr proto.NodeProperty
	fmt.Printf("0x%x, %d\n", pr, pr)

	var pr2 LocalNodeProperty
	fmt.Printf("0x%x, %d\n", pr2, pr2)

	fmt.Println("exit")
}

What did you see happen?

0x7330, 0
0x0, 0
exit

What did you expect to see?

0x0, 0
0x0, 0
exit
@t5w0rd t5w0rd changed the title fmt: Unexpected output for Custom Type Alias of uint8 fmt: Incorrect Hexadecimal Output for Custom Type Alias of uint8 Using fmt.Printf with %x Nov 1, 2024
@seankhliao
Copy link
Member

what is proto.NodeProperty

@seankhliao seankhliao added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Nov 1, 2024
@t5w0rd
Copy link
Author

t5w0rd commented Nov 1, 2024

what is proto.NodeProperty

// in proto/xxx.go
package proto

type NodeProperty uint8

@seankhliao
Copy link
Member

That doesn't reproduce, you most likely have different issues: https://go.dev/play/p/dbiB5MucBk6

Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only.

For questions please refer to https://github.com/golang/go/wiki/Questions

@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Nov 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

3 participants