golang-plugin/tool/go_tool_state.go

32 lines
616 B
Go
Raw Normal View History

2023-07-01 11:18:12 +00:00
package tool
import (
2023-08-15 19:46:36 +00:00
"maps"
2023-08-15 20:10:26 +00:00
"slices"
2023-07-01 11:18:12 +00:00
)
type GoToolState struct {
Env map[string]string `json:"env,omitempty"`
InstalledVersion string `json:"installed_version"`
BuildArgs []string `json:"build_args,omitempty"`
}
func (s GoToolState) Equals(other GoToolState) bool {
if s.InstalledVersion != other.InstalledVersion {
return false
}
if len(s.BuildArgs) != len(other.BuildArgs) {
return false
}
slices.Sort(s.BuildArgs)
slices.Sort(other.BuildArgs)
if !slices.Equal(s.BuildArgs, other.BuildArgs) {
return false
}
return maps.Equal(s.Env, other.Env)
}