go.mod:

module gorm-example

go 1.18

require (
    gorm.io/driver/postgres v1.4.6
    gorm.io/gorm v1.24.3
)

require (
    github.com/jackc/pgpassfile v1.0.0 // indirect
    github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
    github.com/jackc/pgx/v5 v5.2.0 // indirect
    github.com/jinzhu/inflection v1.0.0 // indirect
    github.com/jinzhu/now v1.1.5 // indirect
    golang.org/x/crypto v0.4.0 // indirect
    golang.org/x/text v0.5.0 // indirect
)

main.go:

package main

import (
    "fmt"
    "os"

    "gorm.io/driver/postgres"
    "gorm.io/gorm"
)

func main() {
    db, err := gorm.Open(postgres.Open(os.Getenv("DATABASE_ADDRESS")), &gorm.Config{})
    if err != nil {
        fmt.Println("failed connecting database")
        os.Exit(1)
    }

    var pgVersion string
    err = db.Raw("SELECT version()").Scan(&pgVersion).Error
    if err != nil {
        fmt.Println("failed querying database version", err)
        os.Exit(1)
    }

    fmt.Println("database version:", pgVersion)

    err = db.Exec(
        "CREATE TYPE task_status AS ENUM ?",
        []string{"initial", "running", "finished"},
    ).Error
    if err != nil {
        fmt.Println("failed creating type task_status", err)
        os.Exit(1)
    }
}

output:

database version: PostgreSQL 14.5 on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit

2023/02/01 12:15:34 D:/home/fw/projects/gorm-example/main.go:27 ERROR: syntax error at or near "$1" (SQLSTATE 42601) [3.099ms] [rows:0] CREATE TYPE task_status AS ENUM ('initial','running','finished') failed creating type task_status ERROR: syntax error at or near "$1" (SQLSTATE 42601) exit status 1

Comment From: github-actions[bot]

The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.io ✨ Search Before Asking