Lorlike's Blog
About
Tags
Categories
Hello World
Go使用viper编写配置文件
Go日志logrus
Go令牌jwt
Go文件嵌入embed
Go WEB开发框架gin
Buuctf练习场pwn题
wsl环境搭建
Go WEB开发框架gin
安装go get github.com/gin-gonic/gin 路由HTTP方法常用的GET,POST,PUT,DELETE都支持,还支持一些不常用的方法 package mainimport ( "net/http" "github.com/gin-gonic/gin")func getting(c *gin.Context) { //使用 ...
2026-03-24
Go文件嵌入embed
作用go:embed可以把文件打包到二进制文件中,通过读取内存的方式获取内容 嵌入单文件│ hello.txt│ main.go 上面是目录结构 package mainimport ( _ "embed" "fmt")//go:embed hello.txtvar s stringfunc main() { fmt.Println(s) ...
2026-03-24
Go令牌jwt
前言jwt是一种用于用户认证的数字签名解决方案,形式为header.payload.signature,数据用base64进行编码,signature是把前面的数据与密钥结合进行计算hash的结果,下面是一种hash算法计算signature的方式 HMACSHA256( base64UrlEncode(header) + "." + base64UrlEncode ...
2026-03-24
Go日志logrus
安装go get github.com/sirupsen/logrus 使用package mainimport ( "github.com/sirupsen/logrus")func main() { logrus.SetLevel(logrus.TraceLevel) logrus.Trace("trace msg") logrus. ...
2026-03-24
Go使用viper编写配置文件
安装go get github.com/spf13/viper 读取配置文件支持JSON、TOML、YAML、HCL、envfile和Java properties格式 │ main.go └─config config.go config.yml 比如我的目录像上面那样 # config.ymlapp: # 应用基本配置 env: local # 环境名称 ...
2026-03-24