-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.xml
240 lines (204 loc) · 18 KB
/
index.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>主页 on 技术博客</title>
<link>/</link>
<description>Recent content in 主页 on 技术博客</description>
<generator>Hugo -- gohugo.io</generator>
<language>zh</language><atom:link href="/index.xml" rel="self" type="application/rss+xml" />
<item>
<title>ai</title>
<link>/ai/__index/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>/ai/__index/</guid>
<description> Finetuning Fine tuning的原理就是利用已知的网络结构和已知的网络参数,修改output层为我们自己的层,微调最后一层前的所有层的参数,加大最后一层的学习率,因为最后一层我们需要重新学习,所以与其它层相比要有相对较大的学习率,这样就有效利用了深度神经网络强大的泛化能力,又免去了设计复杂的模型以及耗时良久的训练,所以fine tuning是当数据量不足时的一个比较合适的选择。 </description>
</item>
<item>
<title>context</title>
<link>/golang/context/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>/golang/context/</guid>
<description>未完待续 classDiagram class Context{ << interface >> +Deadline() (deadline time.Time, ok bool) +Done() +Err() error +Value(key any) any } Context <|.. emptyCtx Context <|-- valueCtx class valueCtx{ +Context ~key any ~val any } class canceler{ << interface >> ~cancel(removeFromParent bool, err error) +Done() } canceler <|.. cancelCtx Context <|-- cancelCtx class cancelCtx{ +Context } cancelCtx <|-- timerCtx class timerCtx{ +timer *time.Timer +deadline time.Time } </description>
</item>
<item>
<title>echo</title>
<link>/golang/echo/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>/golang/echo/</guid>
<description>memcached中间件 import ( &#34;bytes&#34; &#34;net/http&#34; &#34;sync&#34; &#34;github.com/bradfitz/gomemcache/memcache&#34; &#34;github.com/labstack/echo/v4&#34; ) var memcacheClientMux sync.Mutex var memcacheClient *memcache.Client // TODO,要不要带上http头部,例如:数据类型html/json/js,Date,Cache-control等等 type middleResp struct { http.ResponseWriter isOK bool key string expiration int32 bytes.Buffer } var StoreErrHandler func(error) func (mr *middleResp) writeStore() { if mr.Buffer.Len() &gt; 0 { err := memcacheClient.Set(&amp;memcache.Item{ Key: mr.key, Flags: 0, Expiration: mr.expiration, Value: mr.Bytes(), }) if StoreErrHandler != nil { StoreErrHandler(err) } } } func (mr *middleResp) Write(body []byte) (int, error) { if mr.</description>
</item>
<item>
<title>exgexp包</title>
<link>/golang/regexp/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>/golang/regexp/</guid>
<description> 正则语法 // 连续的汉字字母数字 var maxHanDigitAlphaReg = regexp.MustCompile(`[\p{Han}[:digit:][:alpha:]]+`) // 单个汉字字母数字 var minHanDigitAlphaReg = regexp.MustCompile(`[\p{Han}[:digit:][:alpha:]]+?`) </description>
</item>
<item>
<title>freetype</title>
<link>/golang/freetype/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>/golang/freetype/</guid>
<description>package main import ( &#34;fmt&#34; &#34;image&#34; &#34;image/draw&#34; &#34;image/png&#34; &#34;os&#34; &#34;github.com/golang/freetype&#34; ) func DrawText(text string) { data, err := ioutil.ReadFile(&#34;/System/Library/Fonts/STHeiti Medium.ttc&#34;) if err != nil { panic(err) } f, err := freetype.ParseFont(data) if err != nil { panic(err) } dst := image.NewRGBA(image.Rect(0, 0, 800, 600)) draw.Draw(dst, dst.Bounds(), image.White, image.Point{}, draw.Src) c := freetype.NewContext() c.SetDst(dst) c.SetClip(dst.Bounds()) c.SetSrc(image.Black) c.SetFont(f) fontSize := float64(50) // 字体越大, 显示越大 c.SetFontSize(fontSize) // Pt是控制起点,Pt{x,y},x表示左起点,y表示下起点,y-fontSize才是上起点 _, err = c.DrawString(text, freetype.Pt(0, int(fontSize))) if err !</description>
</item>
<item>
<title>gin</title>
<link>/golang/gin/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>/golang/gin/</guid>
<description>context中断原理 const abortIndex int8 = math.MaxInt8 / 2 // Abort prevents pending handlers from being called. Note that this will not stop the current handler. // Let&#39;s say you have an authorization middleware that validates that the current request is authorized. // If the authorization fails (ex: the password does not match), call Abort to ensure the remaining handlers // for this request are not called. func (c *Context) Abort() { // c.</description>
</item>
<item>
<title>go-git</title>
<link>/golang/go-git/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>/golang/go-git/</guid>
<description>package main import( &#34;fmt&#34; &#34;github.com/go-git/go-git/v5&#34; &#34;github.com/go-git/go-git/v5/plumbing/object&#34; ) func gitWork() { r, err := git.PlainOpen(&#34;../wubei/wubei&#34;) if err != nil { fmt.Println(err) return } fmt.Println(&#34;r&#34;, r) // ... retrieves the branch pointed by HEAD ref, err := r.Head() if err != nil { fmt.Println(err) return } fmt.Println(&#34;ref&#34;, ref) // ... retrieves the commit history cIter, err := r.Log(&amp;git.LogOptions{From: ref.Hash()}) if err != nil { fmt.Println(err) return } var cCount int err = cIter.</description>
</item>
<item>
<title>golang示例</title>
<link>/grpc/golang/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>/grpc/golang/</guid>
<description>server package main import ( &#34;context&#34; &#34;flag&#34; &#34;fmt&#34; &#34;log&#34; &#34;net&#34; &#34;google.golang.org/grpc&#34; &#34;google.golang.org/grpc/metadata&#34; &#34;google.golang.org/grpc/peer&#34; com &#34;xxx.site/myself/grpc-common&#34; ) var ( GitHash = &#34;Unkown&#34; CompileTime = &#34;Unkown&#34; port = flag.Int(&#34;port&#34;, 8411, &#34;默认端口&#34;) ) // 定义服务端中间件 func middleware(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error) { log.Printf(&#34;middleware ctx:%v&#34;, ctx) log.Printf(&#34;middleware req:%v&#34;, req) log.Printf(&#34;middleware info:%v&#34;, info) log.Printf(&#34;middleware handler:%v&#34;, handler) resp, err = handler(ctx, req) log.Printf(&#34;middleware resp:%v&#34;, resp) log.Printf(&#34;middleware err:%v&#34;, err) return } type MathServer struct { com.</description>
</item>
<item>
<title>io包</title>
<link>/golang/io/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>/golang/io/</guid>
<description>基础 flowchart TB subgraph 单接口 direction LR r1(Reader)---w1(Writer)---c1(Closer)---s1(Seeker) end subgraph 双接口 direction LR rw(ReadWriter)---rc(ReadCloser)---rs(ReadSeeker)---wc(WriteCloser)---ws(WriteSeeker) end subgraph 三接口 direction LR rwc(ReadWriteCloser)---rsc(ReadSeekCloser)---rws(ReadWriteSeeker) end 单接口 --组合--> 双接口 --组合--> 三接口 Reader type Reader interface { // 读取len(p)字节到p里面 // 返回读取成功字节数 // eof表示正常结束 Read(p []byte) (n int, err error) } Writer type Writer interface { // 写入p里面内容,len(p)字节 // 返回写入成功字节数 Write(p []byte) (n int, err error) } 类型 flowchart TB subgraph Byte direction LR br(ByteReader)---bw(ByteWriter)---bc(ByteScanner) end subgraph Rune direction LR rr(RuneReader)---rw(ByteWriter)---rc(ByteScanner) end subgraph String direction LR sw(StringWriter) end 扩展 flowchart TB subgraph 附加 direction LR rf(ReaderFrom)---wt(WriterTo)---ra(ReaderAt)---wa(WriterAt) end subgraph 限制 direction LR lr(LimitedReader)---sr(SectionReader) end subgraph 内部 direction LR d(discard)---nc(nopCloser)---tr(teeReader镜像) mr(multiReader串联)---mw(multiWriter广播) pr(PipeReader就地读)--同个pipe,chan实现---pw(PipeWriter就地写) end 便利函数 WriteString(w Writer, s string) (n int, err error) ReadAll(r Reader) ([]byte, error) ReadFull(r Reader, buf []byte) (n int, err error) ReadAtLeast(r Reader, buf []byte, min int) (n int, err error) CopyN(dst Writer, src Reader, n int64) (written int64, err error) Copy(dst Writer, src Reader) (written int64, err error) CopyBuffer(dst Writer, src Reader, buf []byte) (written int64, err error) //扩展close接口 NopCloser(r Reader)ReadCloser //把r读出来内容写一份到w,镜像r到w TeeReader(r Reader, w Writer) Reader //最多读n个字节,达到就返回eof LimitReader(r Reader, n int64) Reader //串联起多个源头,按顺序依次读完 MultiReader(readers .</description>
</item>
<item>
<title>iris</title>
<link>/golang/iris/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>/golang/iris/</guid>
<description>context中断原理 // I don&#39;t set to a max value because we want to be able to reuse the handlers even if stopped with .Skip const stopExecutionIndex = -1 // StopExecution if called then the following .Next calls are ignored, // as a result the next handlers in the chain will not be fire. func (ctx *context) StopExecution() { ctx.currentHandlerIndex = stopExecutionIndex } // IsStopped checks and returns true if the current position of the context is -1, // means that the StopExecution() was called.</description>
</item>
<item>
<title>log</title>
<link>/golang/log/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>/golang/log/</guid>
<description>日志常用示例 package main import ( &#34;fmt&#34; &#34;io&#34; &#34;io/ioutil&#34; &#34;runtime&#34; &#34;strings&#34; &#34;time&#34; rotatelogs &#34;github.com/lestrrat-go/file-rotatelogs&#34; &#34;github.com/rifflock/lfshook&#34; &#34;github.com/sirupsen/logrus&#34; ) func NewWriter(perfix string) io.Writer { w, err := rotatelogs.New( perfix+&#34;.%Y%m%d.json&#34;, // 建立软接 rotatelogs.WithLinkName(perfix), // 最多保存一星期 rotatelogs.WithMaxAge(7*24*time.Hour), // 一天切割一次 rotatelogs.WithRotationTime(24*time.Hour), ) if err != nil { panic(err) } return w } func InitLog(perfix string) { wm := lfshook.WriterMap{ logrus.DebugLevel: NewWriter(perfix + &#34;_debug&#34;), logrus.InfoLevel: NewWriter(perfix + &#34;_info&#34;), logrus.WarnLevel: NewWriter(perfix + &#34;_warn&#34;), logrus.ErrorLevel: NewWriter(perfix + &#34;_error&#34;), logrus.FatalLevel: NewWriter(perfix + &#34;_fatal&#34;), } logrus.</description>
</item>
<item>
<title>shell</title>
<link>/golang/shell/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>/golang/shell/</guid>
<description>编译常用示例 #! /bin/bash target=local set -x #回显执行命令 GOPATH=$(go env GOPATH) GITVERSION=$(git describe --tags --always) GITBRANCH=$(git symbolic-ref -q --short HEAD) DATETIME=$(date &#34;+%Y-%m-%d_%H:%M:%S&#34;) HOSTNAME=$(hostname) golangci-lint run --timeout=1h revive -formatter friendly ./... rm -rf ${target}* go build -o ${target} -ldflags &#34;-w -s -X main.GitHash=${GITVERSION}-${GITBRANCH} -X main.CompileTime=${DATETIME} -X main.HostName=${HOSTNAME}&#34; . ./${target} </description>
</item>
<item>
<title>sort包</title>
<link>/golang/sort/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>/golang/sort/</guid>
<description> classDiagram Interface <|-- IntSlice : 实现 Interface <|-- Float64Slice : 实现 Interface <|-- StringSlice : 实现 class Interface{ +Len() int +Less(i, j int) bool +Swap(i, j int) } classDiagram Interface <|.. Sort : 依赖 Sort <|-- Ints : []int Sort <|-- Float64s : []float64 Sort <|-- Strings : []string Sort <|-- Slice : []其他类型 classDiagram Search <|-- SearchInts : []int Search <|-- SearchFloat64s : []float64 Search <|-- SearchStrings : []string type Interface interface { Len() int Less(i, j int) bool Swap(i, j int) } // 采用快排/堆排/插排组合 func Sort(data Interface) func Ints(x []int) func Float64s(x []float64) func Strings(x []string) //采用反射自动实现Swap(i, j int) func Slice(x any, less func(i, j int) bool) // 稳排采用分段插排+合并组合 func Stable(data Interface) func SliceStable(x any, less func(i, j int) bool) // 二分搜索有序序列 func Search(n int, f func(int) bool) int func SearchInts(a []int, x int) int func SearchFloat64s(a []float64, x float64) int func SearchStrings(a []string, x string) int </description>
</item>
<item>
<title>stringer</title>
<link>/golang/stringer/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>/golang/stringer/</guid>
<description>官方自动生成string main.go内容 //go:generate stringer -type=Pill type Pill int const ( Placebo Pill = iota Aspirin Ibuprofen Paracetamol Acetaminophen = Paracetamol ) 执行命令 go generate 生成的pill_string.go内容 import &#34;strconv&#34; // 这段防止generate之后,修改后没有再次generate,通过编译错误强制提示 func _() { // An &#34;invalid array index&#34; compiler error signifies that the constant values have changed. // Re-run the stringer command to generate them again. var x [1]struct{} _ = x[Placebo-0] _ = x[Aspirin-1] _ = x[Ibuprofen-2] _ = x[Paracetamol-3] } const _Pill_name = &#34;PlaceboAspirinIbuprofenParacetamol&#34; var _Pill_index = [.</description>
</item>
<item>
<title>常用包</title>
<link>/golang/package/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>/golang/package/</guid>
<description>awesome-宝库值得多看
各个领域优秀库-中文版
lo-基于泛型加强基础功能库
funk-基于泛型加强基础功能库
btree-google开源
exp-官方扩展库值得一看
stl4go-golang版的stl
gorse-推荐系统
goreleaser-简化打包生成各个平台的包
conc-更好用的并发
fsm-有限状态自动机
unioffice-golang读写doc/excel/ppt
cludewego-字节跳动开源框架
fastpb-更快的protobuf
gogo-更快加强版protobuf
template-更快的格式化输出
wails-打包go后端+前端成一个exe
supervisord-golang版supervisor
go-echarts-图形库
go-num-golang版的numpy
colly-爬虫框架
ffmt-更友好fmt
combin-排序组合
set-泛型集合操作
carbon-方便的日期时间库
vugu-纯golang的前端
air-有变化就编码
gota-golang版的pands
plot-golang版plotnine
fyne-跨平台gui
go-git-纯go实现git集成
go-cmp-自定义比较库
golang-opencv绑定
另一个-opencv绑定
pdf-处理pdf库
assert库
gse-golang结巴分词
chardet-编码猜测
edlib-最小编辑距离及相似度
TheAlgorithms-常见算法实现
datastructures-数据结构实现
kratos-微服务
callvis-可视化调用
deadlock-死锁检测
类似json处理csv
cobra-优秀的命令行
更丰富的errors
memcache
redis
mongodb
mysql
grpc
grpc转换http接口
iris
gin
echo
gorm
xorm
发邮件
更快的json
漂亮json输出
从json文档中直接读取相关值
gohook动态替换函数
go-cache-内存缓存
二维码
traceroute-路由跟踪
tesseract-golang调用ocr
在标准输出中彩色输出
combination-组合库</description>
</item>
<item>
<title>代码片断</title>
<link>/golang/code/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>/golang/code/</guid>
<description>更丰富的errors import ( &#34;fmt&#34; &#34;github.com/pkg/errors&#34; ) func main() { //%+v格式输出,则带上栈调用,调试好帮手 fmt.Printf(&#34;err:%+v&#34;, errors.New(&#34;mynew&#34;)) } memcached package main import ( &#34;fmt&#34; //连接memcached &#34;github.com/bradfitz/gomemcache/memcache&#34; ) func main() { key := &#34;/golang&#34; client := memcache.New(&#34;127.0.0.1:11211&#34;) err := client.Set(&amp;memcache.Item{ Key: key, Flags: 0, Expiration: 0, Value: []byte(&#34;&lt;HTML&gt;&lt;H2&gt;hello,golang&lt;/H2&gt;&lt;/HTML&gt;&#34;), }) if err != nil { fmt.Println(err.Error()) return } item, err2 := client.Get(key) if err2 != nil { fmt.Println(err2.Error()) return } fmt.Println(string(item.Value)) } redis package main import ( &#34;fmt&#34; //连接redis &#34;github.</description>
</item>
<item>
<title>泛型</title>
<link>/golang/generic/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>/golang/generic/</guid>
<description>// go 1.18+ package main import ( &#34;fmt&#34; ) type SubType interface { int | string | float32 } // func Sub[T int | string | float32](array []T, ele T) []T { func Sub[T SubType](array []T, ele T) []T { res := make([]T, 0, len(array)) for _, a := range array { if a == ele { continue } res = append(res, a) } return res } func main() { fmt.</description>
</item>
<item>
<title>泛型切片分组</title>
<link>/golang/groupby/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>/golang/groupby/</guid>
<description>func GroupBy[T any, U comparable](collection []T, iteratee func(T) U) map[U][]T { result := map[U][]T{} for _, item := range collection { key := iteratee(item) result[key] = append(result[key], item) } return result } </description>
</item>
</channel>
</rss>