Closed clienthax closed 3 years ago
Looking into this further this seems to be an issue with how omitempty functions
package main
import (
"encoding/json"
"fmt"
)
type TestData struct {
Enabled bool `json:"enabled,omitempty"`
}
func main() {
d := TestData {
Enabled: false,
}
b, _ := json.Marshal(d)
fmt.Println(string(b))
}
if the value is false it is treated as 0, and doesn't get marshaled https://www.sohamkamani.com/blog/golang/2018-07-19-golang-omitempty/
@clienthax, Thaks to open this issue. I am looking for a solution for this though, is there any way to generate bool
to *bool
with go-swagger? Or better solution?
@clienthax, Thaks to open this issue. I am looking for a solution for this though, is there any way to generate
bool
to*bool
with go-swagger? Or better solution?
I am fairly new to Go and this is actually being used in one of my first projects, So I don't have any good solutions here
@kobayashi running into omitempty
issue with https://github.com/netbox-community/go-netbox/issues/86 as well.
Setting Enabled to false will result in it not being added to the query, however setting it to true will add it when using the update/create interface functions.