#4526·ent

GoType() doesn't support generic methods from other packages

Author: nemithCreated Oct 1, 2026Updated Oct 1, 2026
  • The issue is present in the latest release.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Current Behavior

GoType accepts instantiated generic types, but produces incorrect package names when a type argument belongs to another package.

For example, Text[string] works, while Text[time.Time] produces main.Text[time as the package name. The descriptor reports no error. When used in a schema, the malformed package name produces invalid import aliases and code generation fails with missing import path.

There is also a related type-expression problem: Text[uuid.UUID] is represented as main.Text[github.com/google/uuid.UUID]. Copying this directly into generated code produces invalid Go syntax, even after correcting the package name.

Expected Behavior

GoType should correctly identify the outer type’s package and generate valid type expressions and imports for its type arguments.

In the reproduction below, PkgName should be main for all three types.

Steps to Reproduce

  1. Use the following repo file:
go
  package main

  import (
        "fmt"
        "time"

        "entgo.io/ent/schema/field"
        "github.com/google/uuid"
  )

  type Text[T any] string

  func main() {
        for _, value := range []any{
                Text[string](""),
                Text[time.Time](""),
                Text[uuid.UUID](""),
        } {
                d := field.String("value").GoType(value).Descriptor()
                fmt.Printf("type: %s\npackage: %s\nerror: %v\n\n",
                        d.Info.Ident, d.Info.PkgName, d.Err)
        }
  }
  1. run go run repro.go

  2. Observe the malformed package names and the full import path inside the UUID type argument:

  type: main.Text[string]
  package: main
  error: <nil>

  type: main.Text[time.Time]
  package: main.Text[time
  error: <nil>

  type: main.Text[github.com/google/uuid.UUID]
  package: main.Text[github.com/google/uuid
  error: <nil>

Your Environment

Tech Version
Go 1.27.1
Ent 0.14.6
Database Not Required
Driver Not Required