
go
在踩坑中前进
我是人间惆怅客
展开
-
go注册到consul
package coreimport ( "log" consulapi "github.com/hashicorp/consul/api")func RegService() { config := consulapi.DefaultConfig() config.Address = "127.0.0.1:8500" //consul地址 reg := consulapi.AgentServiceRegistration{} reg.Name = "ilocal-golang-s.原创 2022-03-11 17:50:02 · 539 阅读 · 0 评论 -
go操作elasticsearch
package mainimport ( "context" "fmt" "log" "os" "reflect" "github.com/olivere/elastic/v7")var client *elastic.Clientvar host = "http://127.0.0.1:9200/"type Employee struct { FirstName string `json:"first_name"` LastName string `json:".原创 2022-01-07 19:03:59 · 278 阅读 · 0 评论 -
go操作redis
package mainimport ( "fmt" "github.com/garyburd/redigo/redis")func main() { c, err := redis.Dial("tcp", "localhost:6379") if err != nil { fmt.Println("conn redis failed,", err) defer c.Close() return } fmt.原创 2022-01-07 18:28:18 · 1031 阅读 · 0 评论 -
go操作mysql
package mainimport ( "fmt" _ "github.com/go-sql-driver/mysql" "github.com/jmoiron/sqlx")type Person struct { Id int `db:"id"` Name string `db:"name"` Age string `db:"age"`}var Db *sqlx.DBfunc init() { databa.原创 2022-01-07 18:13:28 · 528 阅读 · 0 评论 -
go mod
mkdir hellocd hellogo mod init hello原创 2022-01-07 18:10:25 · 86 阅读 · 0 评论