Closed
Description
Description
Hi! While doing a broad search for this pattern, I noticed that you use "omitempty"
as the name of a structure field.
Line 47 in cd225d7
Instead, I believe you intended to use ",omitempty"
to keep the default name and add the omitempty
option.
You can test this behavior with this simple Go program. As you can see by the result, the omitempty
key in the JSON string gets unmarshaled to the field with the json:"omitempty"
tag.
package main
import (
"encoding/json"
"fmt"
)
type SomeStruct struct {
SomeField string `json:"omitempty"`
}
func main() {
u := SomeStruct{}
_ = json.Unmarshal([]byte(`{"omitempty": "123"}`), &u)
fmt.Printf("Result: %#v\n", u)
// Result: main.SomeStruct{SomeField:"123"}
}
Gitea Version
Can you reproduce the bug on the Gitea demo site?
No
Log Gist
No response
Screenshots
No response
Git Version
No response
Operating System
No response
How are you running Gitea?
Database
None