How do I use prepared statements using GORM?

GORM is a powerful ORM tool for Go that provides an easy way to interact with databases and use prepared statements to enhance security and performance of your queries.
GORM, Go programming, prepared statements, ORM, database interaction

package main

import (
    "github.com/jinzhu/gorm"
    _ "github.com/jinzhu/gorm/dialects/sqlite"
    "log"
)

type User struct {
    ID   uint   `gorm:"primary_key"`
    Name string `gorm:"size:255"`
    Age  uint
}

func main() {
    db, err := gorm.Open("sqlite3", "test.db")
    if err != nil {
        log.Fatal(err)
    }
    defer db.Close()

    // Migrate the schema
    db.AutoMigrate(&User{})

    // Prepare statement
    stmt, err := db.DB().Prepare("INSERT INTO users (name, age) VALUES (?, ?)")
    if err != nil {
        log.Fatal(err)
    }
    defer stmt.Close()

    // Execute prepared statement
    _, err = stmt.Exec("Alice", 30)
    if err != nil {
        log.Fatal(err)
    }

    log.Println("User added successfully")
}
    

GORM Go programming prepared statements ORM database interaction