package main import ( "encoding/json" "fmt" "log" "net" "sync" "time" ) type Config struct { ID string `json:"ID"` ServerIP string `json:"serverip"` ServerPort int `json:"serverpor
import ( "golang.org/x/time/rate" "io" ) type rateLimitedReader struct { r io.Reader limiter *rate.Limiter } func (rlr *rateLimitedReader) Read(p []byte) (int, error) { n, err := rl
func CreateId(db *gorm.DB) int { var configs []Config db.Select("pname").Find(&configs) var usedNumbers []int for _, config := range configs { if strings.HasPrefix(config.Pname, "ppp") {
a := []string{} a1 := strings.Join(a, "\n") reader := bytes.NewBuffer([]byte(a1)) cHttp := &http.Client{Timeout: 10 * time.Second} resp, _ := http.NewRequest("POST", "http://localhost:8086/api
更换GORM默认的SQLite驱动在GORM官方的Issues发现也有人反馈此类问题,于是顺藤摸瓜,找到了github.com/glebarez/sqlite这个库,该库使用纯go实现,不依赖CGO,地址是:https://github.com/glebarez/sqlite于是将官方的驱动:import ( "gorm.io/driver/sqlite" "gorm.io/gor
package check import ( "context" "fmt" "github.com/influxdata/influxdb-client-go/v2/api/write" "github.com/shirou/gopsutil/cpu" "log" "time" influxdb2 "github.com/influxdata/influxdb-client-g
package main import ( "fmt" "log" "time" "github.com/shirou/gopsutil/cpu" ) func main() { // 获取CPU核心数 cpuCount, err := cpu.Counts(true) if err != nil { log.Fatal("Failed to get CPU core co
https://github.com/hequan2017/GoTerminalQRCode 用这个项目 二进制打包之后。 加-t参数。 就可以正常显示。
package main import ( "fmt" stun "github.com/ppma/nat-type" ) const ( STUN_SERVER = "stun.qq.com" STUN_PORT = 3478 ) func main() { localAddr := fmt.Sprintf("%s:%d", "192.168.8.109", 8569) s
package main import ( "fmt" "math/rand" "net" "time" ) func main() { ppp := struct{ Mac string }{""} if ppp.Mac == "" { rand.Seed(time.Now().UnixNano()) // 使用当前时间为随机数生成器设置种子 mac := make(n
package mainimport ( "context" "github.com/go-redis/redis/v8" "log" "sync")var ctx = context.Background()func ProducerMessageList(rdb *redis.Client, queueListKey string) { for i := 0; i
package mainimport ( "context" "github.com/go-redis/redis/v8" "log")var ctx = context.Background()func ProducerMessageList(rdb *redis.Client, queueListKey string) { for i := 0; i < 1000
package mainimport ( "context" "github.com/go-redis/redis/v8" "log" "math/rand" "time")var ctx = context.Background()func ProducerMessageList(rdb *redis.Client, queueListKey string) {
github 关键词 go-ppp-console
package qrimport ( "context" "fmt" "github.com/mum4k/termdash/align" "github.com/mum4k/termdash/linestyle" "github.com/mum4k/termdash/widgets/text" "time" "github.com/mum4k/termda
package pppimport ( "gorm.io/gorm")type PppService struct {}type PppSearch struct { PppData PageInfo}type IdsReq struct { Ids []int `json:"ids" form:"ids"`}type PageInfo struct { Page
package mainimport ( "fmt" "github.com/c-bata/go-prompt" "os" "os/signal" "syscall")func base(d prompt.Document) []prompt.Suggest { s := []prompt.Suggest{ {Text: "1", Description: "网卡配置"},
IOCountersStat, _ := gopsutil.IOCounters(true) loc, _ := time.LoadLocation("Asia/Shanghai") now := time.Now() NewNow := now.In(loc).Format("2006-01-02 15:04:00") NewDt, _ := time.Parse
package mainimport ( "encoding/csv" "fmt" "log" "math/big" "os" "sort" "strconv")func main() { filename := "1.csv" ReadCsv(filename)}func ReadCsv(filepath string) { openc
package mainimport ( "encoding/hex" "fmt" "github.com/gogf/gf/v2/crypto/gaes")func main() { key := []byte("B4OcDhdFwIyDdjFz") // 16位 res, _ := gaes.Encrypt([]byte("hequan"), key) res2 := hex.Enc
package mainimport ( "database/sql" "fmt" _ "github.com/wenj91/taos-driver" "time")func main() { var taosUri = "root:taosdata@http(192.168.X.X:6041)/teledb" taos, err := sql.Open("ta
$ go get github.com/mitchellh/gox...$ gox -h...## 只打包linuxgox -osarch="linux/amd64"
package yilongsyncimport ( "context" "time")var Ctx = context.TODO()type CityPostStruct struct { Version string Local string Request struct { CountryType string CityIdType string Page
package jielvimport ( "encoding/xml" "github.com/PuerkitoBio/goquery" "io/ioutil" "log" "net/http" "strings")func getXML() []byte { url := "http://" resp, _ := http.Get(url) defer resp.Body.C
package mainimport "fmt"func main() { repeat := 0 pagesize := 10 count := 150 /* 循环 */LOOP: firstResult := repeat * pagesize for repeat < 1000 { fmt.Println("一共150个数据,一次请求10个, 本次是第", repea
func StringStrip(input string) string { if input == "" { return "" } reg := regexp.MustCompile(`[\s\p{Zs}]{1,}`) return reg.ReplaceAllString(input, "-")}a := StringStrip(strings.TrimSpace(v))fm
servergopackagemainimport("fmt""github.com/gocelery/gocelery""github.com/gomodule/redigo/redis""time")funcmain(){//createredisconnectionpoolredisPool:=&redis.Pool{Dial:func()(redis.Conn,error){c,err:=
gopackagemainimport("context""github.com/minio/miniogo/v7""github.com/minio/miniogo/v7/pkg/credentials""log")funcmain(){ctx:=context.Background()endpoint:="192.168.1.2:9001"accessKeyID:="minioadmin"se
效果图!39GILT21N2KAKSBKT_7.png(https://s2.51cto.com/images/20210831/1630401994207568.png?xossprocess=image/watermark,size_14,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_20,type_ZmFuZ3p
Copyright © 2005-2025 51CTO.COM 版权所有 京ICP证060544号