Two fixes in our Go API code: (#5066)

* Replace `interface{}` with `any`
* For options that are bools, don't always set true; set to the actual
  value passed in (some options already behaved this way, but they all
  should)
This commit is contained in:
Jeff Mitchell authored and GitHub committed 2024-09-04 11:40:43 -04:00
1 parent 4e8e069c9c
commit 35d1df7388
72 files changed
+510 -475

No files matched your search

+1 -1
View File
@@ -59,7 +59,7 @@ type HostDeleteResult struct {
}
// GetItem will always be nil for HostDeleteResult
func (n HostDeleteResult) GetItem() interface{} {
func (n HostDeleteResult) GetItem() any {
return nil
}
+7 -7
View File
@@ -20,7 +20,7 @@ import (
type Option func(*options)
type options struct {
postMap map[string]interface{}
postMap map[string]any
queryMap map[string]string
withAutomaticVersioning bool
withSkipCurlOutput bool
@@ -30,7 +30,7 @@ type options struct {
func getDefaultOptions() options {
return options{
postMap: make(map[string]interface{}),
postMap: make(map[string]any),
queryMap: make(map[string]string),
}
}
@@ -69,7 +69,7 @@ func WithAutomaticVersioning(enable bool) Option {
// Useful for when we need to look up versions.
func WithSkipCurlOutput(skip bool) Option {
return func(o *options) {
o.withSkipCurlOutput = true
o.withSkipCurlOutput = skip
}
}
@@ -94,9 +94,9 @@ func WithStaticHostAddress(inAddress string) Option {
return func(o *options) {
raw, ok := o.postMap["attributes"]
if !ok {
raw = interface{}(map[string]interface{}{})
raw = any(map[string]any{})
}
val := raw.(map[string]interface{})
val := raw.(map[string]any)
val["address"] = inAddress
o.postMap["attributes"] = val
}
@@ -106,9 +106,9 @@ func DefaultStaticHostAddress() Option {
return func(o *options) {
raw, ok := o.postMap["attributes"]
if !ok {
raw = interface{}(map[string]interface{}{})
raw = any(map[string]any{})
}
val := raw.(map[string]interface{})
val := raw.(map[string]any)
val["address"] = nil
o.postMap["attributes"] = val
}
+1 -1
View File
@@ -14,7 +14,7 @@ type StaticHostAttributes struct {
Address string `json:"address,omitempty"`
}
func AttributesMapToStaticHostAttributes(in map[string]interface{}) (*StaticHostAttributes, error) {
func AttributesMapToStaticHostAttributes(in map[string]any) (*StaticHostAttributes, error) {
if in == nil {
return nil, fmt.Errorf("nil input map")
}