# Test that a get go works for kubernetes types,
# including those special cases that result in _ and string
# that are specifically mentioned in help get go.

exec cue get go --local .
cmp ./file2_go_gen.cue ./file2_go_gen.cue.golden

# Check that the resulting CUE is valid
exec cue vet -c=false

-- go.mod --
module mod.test

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

// +k8s:openapi-gen=true
-- file2.go --
package pkg1

type Foo struct {
	Regular          string  `json:"regular"`
	Pointer          *string `json:"pointer"`
	OmitEmpty        string  `json:"omitEmpty,omitempty"`
	OmitEmptyPointer *string `json:"omitEmptyPointer,omitempty"`

	// +required
	Required string `json:"required"`
	// +required
	RequiredPointer *string `json:"requiredPointer"`

	// +optional
	Optional string `json:"optional"`
	// +optional
	OptionalPointer *string `json:"optionalPointer"`

	// +nullable
	Nullable string `json:"nullable"`
	// +nullable
	NullablePointer *string `json:"nullablePointer"`

	// +required
	// +nullable
	RequiredNullable string `json:"requiredNullable"`
	// +required
	// +nullable
	RequiredNullablePointer *string `json:"requiredNullablePointer"`

	// +optional
	// +nullable
	OptionalNullable string `json:"optionalNullable"`
	// +optional
	// +nullable
	OptionalNullablePointer *string `json:"optionalNullablePointer"`
}
-- file2_go_gen.cue.golden --
// Code generated by cue get go. DO NOT EDIT.

//cue:generate cue get go mod.test

package pkg1

#Foo: {
	regular:           string @go(Regular)
	pointer?:          string @go(Pointer,*string)
	omitEmpty?:        string @go(OmitEmpty)
	omitEmptyPointer?: string @go(OmitEmptyPointer,*string)

	// +required
	required: string @go(Required)

	// +required
	requiredPointer: string @go(RequiredPointer,*string)

	// +optional
	optional?: string @go(Optional)

	// +optional
	optionalPointer?: string @go(OptionalPointer,*string)

	// +nullable
	nullable: null | string @go(Nullable,string)

	// +nullable
	nullablePointer?: null | string @go(NullablePointer,*string)

	// +required
	// +nullable
	requiredNullable: null | string @go(RequiredNullable,string)

	// +required
	// +nullable
	requiredNullablePointer: null | string @go(RequiredNullablePointer,*string)

	// +optional
	// +nullable
	optionalNullable?: null | string @go(OptionalNullable,string)

	// +optional
	// +nullable
	optionalNullablePointer?: null | string @go(OptionalNullablePointer,*string)
}
