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

WritableDeviceInterface Enabled is not added to query #54

Closed
clienthax opened this issue Jan 15, 2020 · 5 comments
Closed

WritableDeviceInterface Enabled is not added to query #54

clienthax opened this issue Jan 15, 2020 · 5 comments

Comments

@clienthax
Copy link

clienthax commented Jan 15, 2020

	params := models.WritableDeviceInterface{
		Name:        &swInterface.name,
		MacAddress:  &swInterface.info.IfaceObj.Mac,
		Device:      &parentDeviceID,
		Enabled:     false,
		FormFactor:  formFactor,
		TaggedVlans: []int64{},
		Tags:        []string{},
		Mtu:         &mtu64,
	}

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.

@clienthax
Copy link
Author

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
Copy link
Author

golang/go#13284

@kobayashi
Copy link
Contributor

@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
Copy link
Author

clienthax commented Feb 10, 2020

@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

@abhide
Copy link
Contributor

abhide commented Jun 24, 2020

@kobayashi running into omitempty issue with #86 as well.

@awlx awlx closed this as completed Oct 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants