随笔分类 -  Go

上一页 1 ··· 4 5 6 7 8 9 下一页
该文被密码保护。
posted @ 2023-11-07 17:27 朝阳1 阅读(843) 评论(7) 推荐(0)
摘要:package main import ( "context" "fmt" "github.com/minio/minio-go/v7" "github.com/minio/minio-go/v7/pkg/credentials" "io" "log" "mime" "os" "path/filep 阅读全文
posted @ 2023-11-07 17:21 朝阳1 阅读(436) 评论(0) 推荐(0)
摘要:go-zero对接分布式事务dtm保姆式教程 一、首先需要注意 go-zero 1.2.4版本以上,这个一定要注意 dtm 你用最新的就行了 二、clone dtm git clone https://github.com/yedf/dtm.git 三、配置文件 1、找到项目跟文件夹下的conf.s 阅读全文
posted @ 2023-11-07 16:54 朝阳1 阅读(267) 评论(0) 推荐(0)
摘要:package main import ( "io" "net" "os/exec" ) func main() { var ( listener net.Listener err error conn net.Conn ) listener, err = net.Listen("tcp", ":8 阅读全文
posted @ 2023-11-07 09:34 朝阳1 阅读(134) 评论(0) 推荐(0)
摘要:上一篇简单使用了grpcGolang简单使用grpc server package main import ( "fmt" "golang.org/x/net/context" "google.golang.org/grpc" "google.golang.org/grpc/codes" "goog 阅读全文
posted @ 2023-11-06 16:28 朝阳1 阅读(71) 评论(0) 推荐(0)
摘要:接着上篇文章 Golang实现grpc单向认证 注意事项 前面我们生成的根证书是ca.crt,在双向认证时,我使用的是ca.pem,所以需要更改一下证书的类型。 只需将1.4的生成ca.crt的命令改为ca.pem即可 4 修改根证书生成命令 4.1.1 生成ca秘钥,得到ca.key【命令与1.2 阅读全文
posted @ 2023-11-06 16:17 朝阳1 阅读(961) 评论(0) 推荐(0)
摘要:接着上篇文章写 Golang 简单使用grpc golang 1.15+版本上,用 gRPC通过TLS实现数据传输加密时,会报错证书的问题: rpc error: code = Unavailable desc = connection error: desc = "transport: authe 阅读全文
posted @ 2023-11-06 16:09 朝阳1 阅读(232) 评论(0) 推荐(0)
摘要:文件夹格式 编写proto syntax = "proto3"; // 指定proto版本 package pb; // 指定默认包名 // 指定golang包名 // 指令 protoc -I . --go_out=. --go-grpc_out=. ./hello.proto // protoc 阅读全文
posted @ 2023-11-06 16:00 朝阳1 阅读(76) 评论(0) 推荐(0)
摘要:docker安装 docker run -d --name emqx -p 1883:1883 -p 8083:8083 -p 8084:8084 -p 8883:8883 -p 18083:18083 emqx/emqx:5.8.0 示例使用使用EMQX提供的免费公共 MQTT 服务器,该服务基于 阅读全文
posted @ 2023-11-04 16:39 朝阳1 阅读(517) 评论(0) 推荐(0)
摘要:1:defer的执行顺序 多个defer出现的时候,它是一个“栈”的关系,也就是先进后出。一个函数中,写在前面的defer会比写在后面的defer调用的晚 package main import "fmt" func main() { defer func1() defer func2() defe 阅读全文
posted @ 2023-11-03 09:40 朝阳1 阅读(25) 评论(0) 推荐(0)
摘要:package main import ( "fmt" ) // 定义坐标结构 type Coordinate struct { x, y int } // 定义地图大小 const ( rows = 4 cols = 4 ) // 定义地图数组 var grid = [][]int{ {0, 1, 阅读全文
posted @ 2023-10-21 15:16 朝阳1 阅读(28) 评论(0) 推荐(0)
摘要:logrus目前以及不维护了,care的话可以用zap package xlog import ( "bufio" "fmt" "github.com/sirupsen/logrus" rotatelogs "github.com/lestrrat-go/file-rotatelogs" "gith 阅读全文
posted @ 2023-10-21 14:53 朝阳1 阅读(129) 评论(0) 推荐(0)
摘要:go get github.com/spf13/viper config.toml title = "toml exaples" redis = "127.0.0.1:3300" [mysql] host = "192.168.1.1" ports = 3306 username = "root" 阅读全文
posted @ 2023-10-21 14:27 朝阳1 阅读(90) 评论(0) 推荐(0)
摘要:WaitGroup 主要用于控制任务组下的并发子任务。它的具体做法就是,子任务 goroutine 执行前通过 Add 方法添加任务数目,子任务 goroutine 结束时调用 Done 标记已完成任务数,主任务 goroutine 通过 Wait 方法等待所有的任务完成后才能执行后续逻辑 pack 阅读全文
posted @ 2023-10-21 14:10 朝阳1 阅读(72) 评论(0) 推荐(0)
摘要:package main import ( "fmt" _ "github.com/go-sql-driver/mysql" "xorm.io/xorm" ) type PointInfo struct { Id int64 `xorm:"pk autoincr"` ProductKey strin 阅读全文
posted @ 2023-10-21 13:59 朝阳1 阅读(130) 评论(0) 推荐(0)
摘要:有时候拼接es语法太麻烦了,熟悉mysql的同学可以用mysql语法,6.X以上的es版本都支持 package main import ( "bytes" "encoding/json" "fmt" "github.com/elastic/go-elasticsearch/v8" "log" ) 阅读全文
posted @ 2023-10-20 15:55 朝阳1 阅读(90) 评论(0) 推荐(0)
摘要:package main import "fmt" // MyInt ~表示不仅支持int8, 还支持int8的衍生类型int8A和int8B type MyInt interface { int | ~int8 | int16 | int32 | int64 } func getMaxNum[T 阅读全文
posted @ 2023-10-20 11:15 朝阳1 阅读(30) 评论(0) 推荐(0)
摘要:首先新建Service,名称叫做server-api vim /lib/systemd/system/server-api.service 或者 vim /etc/systemd/system/server-api.service [Unit] Description=grave server [S 阅读全文
posted @ 2023-10-20 11:09 朝阳1 阅读(70) 评论(1) 推荐(0)
摘要:项目目录 ├── asset // 静态资源文件 │ ├── bootstrap.min.css │ ├── bootstrap.min.js │ └── jquery.js ├── go.mod ├── go.sum ├── html // html模版文件 │ └── index.html └─ 阅读全文
posted @ 2023-10-20 10:47 朝阳1 阅读(339) 评论(0) 推荐(0)
摘要:1,借助linux系统命令 /usr/bin/uuidgen 1.1 代码 package main import ( "fmt" "log" "os/exec" ) func main(){ out,err := exec.Command("uuidgen").Output() if err!=n 阅读全文
posted @ 2023-10-19 10:45 朝阳1 阅读(360) 评论(0) 推荐(0)

上一页 1 ··· 4 5 6 7 8 9 下一页