摘要: package main import ( "fmt" "gorm.io/driver/mysql" "gorm.io/gorm" ) type Product struct { gorm.Model Code string Price uint } func main() { dsn := "ro 阅读全文
posted @ 2023-04-17 16:13 李若盛开 阅读(29) 评论(0) 推荐(0)
摘要: Go 1.16新特性:embed包及其使用详解 embed是什么 embed是在Go 1.16中新加包。它通过//go:embed指令,可以在编译阶段将静态资源文件打包进编译好的程序中,并提供访问这些文件的能力。 为什么需要embed包 部署过程更简单。传统部署要么需要将静态资源与已编译程序打包在一 阅读全文
posted @ 2023-04-17 00:15 李若盛开 阅读(70) 评论(0) 推荐(0)
摘要: go在1.16之后引入了一个新包 embed,它使我们访问工程内的代码变的相对容易 概览 它支持讲内部文件转换为 string, []byte和一个embed像是的fs结构。 用法如下 import _ "embed" //go:embed hello.txt var s string print( 阅读全文
posted @ 2023-04-17 00:12 李若盛开 阅读(92) 评论(0) 推荐(0)