Documentation ¶
Index ¶
Examples ¶
Constants ¶
View Source
const ( DriverName = "mysql" DSN = "MYSQL_DSN" )
Variables ¶
This section is empty.
Functions ¶
func GetEnv ¶
func GetEnv() (halfDsn string)
Example ¶
package main import ( "database/sql" "fmt" "github.com/zhangxiaofeng05/com/db/com_mysql" ) func main() { // $ go get github.com/go-sql-driver/mysql // import _ "github.com/go-sql-driver/mysql" halfDsn := com_mysql.GetEnv() dsn := fmt.Sprintf("%s/%s?parseTime=true", halfDsn, "dev") fmt.Println(dsn) db, err := sql.Open(com_mysql.DriverName, dsn) if err != nil { panic(err) } defer db.Close() err = db.Ping() if err != nil { panic(err) } }
Output:
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.