module mainimport db.pgstructUser { id int name string age int}pub fn (user User) next() User {return user}fnmain() { db_config := pg.Config{ //数据库连接配置 host: 'localhost' user: 'postgres' password: '' dbname: 'test_db' } db := pg.connect(db_config) or { //连接数据库,如果连接失败,抛出错误panic('连接错误:err') } rows := db.exec('select * from users') or { panic(err) } //方式1:执行SQL语句字符串for row in rows {println(row) } users := sql db {select from User where id ==1 }!println(users)for u in users {println(u) }}