# Test default behavior (json,yaml)
exec cue get go --local ./...
cmp ./pkg/pkg_go_gen.cue ./pkg/pkg_go_gen_default.cue.golden

# Test yaml priority
exec cue get go --local --codec=yaml,json ./...
cmp ./pkg/pkg_go_gen.cue ./pkg/pkg_go_gen_yaml.cue.golden

# Test yaml only
exec cue get go --local --codec=yaml ./...
cmp ./pkg/pkg_go_gen.cue ./pkg/pkg_go_gen_yaml_only.cue.golden

-- go.mod --
module mod.test

go 1.21
-- cue.mod/module.cue --
module: "mod.test"
language: version: "v0.15.0"
-- pkg/pkg.go --
package pkg

type OnlyJson struct {
	F1 int `json:"f1_json"`
	F2 int
}

type OnlyYaml struct {
	F1 int `yaml:"f1_yaml"`
	F2 int
}

type Overlapping struct {
	F1 int `json:"f1_json" yaml:"f1_yaml"`
	F2 int `json:"f2_json"`
}

type Disjoint struct {
	F1 int `json:"f1_json"`
	F2 int `yaml:"f2_yaml"`
}
-- pkg/pkg_go_gen_default.cue.golden --
// Code generated by cue get go. DO NOT EDIT.

//cue:generate cue get go mod.test/pkg

package pkg

#OnlyJson: {
	f1_json: int @go(F1)
	F2:      int
}

#OnlyYaml: {
	f1_yaml: int @go(F1)
	F2:      int
}

#Overlapping: {
	f1_json: int @go(F1)
	f2_json: int @go(F2)
}

#Disjoint: {
	f1_json: int @go(F1)
	f2_yaml: int @go(F2)
}
-- pkg/pkg_go_gen_yaml.cue.golden --
// Code generated by cue get go. DO NOT EDIT.

//cue:generate cue get go mod.test/pkg --codec=yaml,json

package pkg

#OnlyJson: {
	f1_json: int @go(F1)
	F2:      int
}

#OnlyYaml: {
	f1_yaml: int @go(F1)
	F2:      int
}

#Overlapping: {
	f1_yaml: int @go(F1)
	f2_json: int @go(F2)
}

#Disjoint: {
	f1_json: int @go(F1)
	f2_yaml: int @go(F2)
}
-- pkg/pkg_go_gen_yaml_only.cue.golden --
// Code generated by cue get go. DO NOT EDIT.

//cue:generate cue get go mod.test/pkg --codec=yaml

package pkg

#OnlyJson: {
	F1: int
	F2: int
}

#OnlyYaml: {
	f1_yaml: int @go(F1)
	F2:      int
}

#Overlapping: {
	f1_yaml: int @go(F1)
	F2:      int
}

#Disjoint: {
	F1:      int
	f2_yaml: int @go(F2)
}