You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (go env)?
GOHOSTARCH='amd64'
GOHOSTOS='linux'
What did you do?
Marshal my struct error,code like this:
package main
import (
"encoding/json"
"fmt"
)
type W2 interface {
json.Marshaler
json.Unmarshaler
}
type Data struct {
ID string `json:"id"`
W2 `json:"-"`
}
func main() {
var d Data
marshal, err := json.Marshal(d)
if err != nil {
return
}
fmt.Println(string(marshal))
}
Because of embedding, the methods get promoted.
closing as while unfortunate, this is how the language works.
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.
What version of Go are you using (
go version
)?go version go1.21rc3 linux/amd64
Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?GOHOSTARCH='amd64'
GOHOSTOS='linux'
What did you do?
Marshal my struct error,code like this:
and I got error:
What did you expect to see?
Struct W2's tag is ``json:"-"` ,may not be check in marshal?
What did you see instead?
And I got a panic.
The text was updated successfully, but these errors were encountered: