File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -1081,10 +1081,19 @@ func (e *extractor) makeType(typ types.Type) (result cueast.Expr) {
1081
1081
// fall back to whatever alternative type we can, or just "top".
1082
1082
// Otherwise we would end up generating "std" packages which clash with our
1083
1083
// own standard library, for example cue.mod/gen/time.
1084
+ //
1085
+ // Go defines standard library as "no dot in the first path element",
1086
+ // such that "foo/bar.baz" is still technically part of the standard library.
1087
+ // Note that "example" and "test" are reserved for users in Go, such that "test/foo"
1088
+ // is not part of Go's standard library, but such exceptions do not exist in CUE.
1089
+ // TODO: never place such packages under e.g. cue.mod/gen/example, as that clashes
1090
+ // with CUE's own standard library namespace at the moment.
1091
+ //
1084
1092
// TODO: for cases where the Go std type could be supported, we could still generate
1085
1093
// and import it under a non-std CUE package, such as cue.mod/gen/pkg.go.dev/time.
1086
1094
// TODO: Doc?
1087
- if ! strings .ContainsAny (pkg .Path (), "." ) {
1095
+ firstElem , _ , _ := strings .Cut (pkg .Path (), "/" )
1096
+ if ! strings .ContainsAny (firstElem , "." ) {
1088
1097
if s := e .altType (obj .Type ()); s != nil {
1089
1098
return s
1090
1099
}
You can’t perform that action at this time.
0 commit comments