exec cue exp gengotypes
cmp cue_types_p_gen.go expect-gengo

# The resulting Go should all build without error.
go build ./...

-- go.mod --
module "mod.test"

go 1.22
-- cue.mod/module.cue --
module: "mod.test"
language: {
	version: "v0.13.0"
}
deps: {
	"example.com@v0": {
		v: "v0.0.1"
	}
}
-- aliased.cue --
package p

import (
	// Two "v1" packages imported in the same file, one with an alias.
	v1_aliased "mod.test/api/meta/v1"
	"mod.test/api/core/v1"
)

#Aliased: {
	meta: v1_aliased.#ObjectMeta
	spec: v1.#PodSpec
}
-- alias_conflict1.cue --
package p

// Two files import two different packages under the same alias.
import same "mod.test/foo"

#Conflict: foo: same.#Foo
-- alias_conflict2.cue --
package p

import same "mod.test/bar"

#Conflict: bar: same.#Bar
-- qualified.cue --
package p

// A qualified import from a directory holding multiple packages.
import "mod.test/many:foo"

#Qualified: foo.#Foo
-- external.cue --
// TODO: decide how gengotypes should deal with external CUE dependencies.
// What is a reasonable place to generate their Go types?
// package p

import "example.com/many@v0:foo"

#External: {
	versionedAndQualified: foo.#Foo
}
-- api/meta/v1/types.cue --
package v1

#ObjectMeta: {}

-- api/core/v1/types.cue --
package v1

#PodSpec: {}

-- foo/foo.cue --
package foo

#Foo: int

-- bar/bar.cue --
package bar

#Bar: string
-- many/foo.cue --
package foo

#Foo: int
-- many/bar.cue --
package bar

#Bar: int

-- expect-gengo --
// Code generated by "cue exp gengotypes"; DO NOT EDIT.

package p

import (
	"mod.test/api/core/v1"
	v1_aliased "mod.test/api/meta/v1"
	same1 "mod.test/bar"
	same "mod.test/foo"
	"mod.test/many"
)

type Aliased struct {
	Meta v1_aliased.ObjectMeta `json:"meta"`

	Spec v1.PodSpec `json:"spec"`
}

type Conflict struct {
	Bar same1.Bar `json:"bar"`

	Foo same.Foo `json:"foo"`
}

type Qualified foo.Foo
-- _registry/example.com_v0.0.1/cue.mod/module.cue --
module: "example.com@v0"
language: version: "v0.8.0"

-- _registry/example.com_v0.0.1/many/foo.cue --
package foo

#Foo: int
-- _registry/example.com_v0.0.1/many/bar.cue --
package bar

#Bar: int
