import "github.com/jinzhu/gorm" type User struct { gorm.Model Name string Email string Age int Active bool }
db.AutoMigrate(&User{})
// Find user by ID var user User db.First(&user, 1) // Find all active users var users []User db.Where("active = ?", true).Find(&users) // Find the youngest user var youngest User db.Order("age asc").First(&youngest)These examples demonstrate some of the ways Gorm can be used to query and retrieve data from a database table. The `First` function retrieves the first record that matches a given condition (in this case, ID = 1). The `Where` function allows you to specify more complex conditions for filtering records, and the `Find` function retrieves all records that match the condition. The `Order` function can be used to sort records before retrieving them. Overall, github.com/jinzhu/gorm is a powerful and flexible package for working with databases in Go. Its easy-to-use API and support for multiple database backends make it a popular choice for many Go developers.