go 的分页器:
参考: https://github.com/vcraescu/go-paginator
代码:https://files.cnblogs.com/files/zach0812/go_paginator.zip
go 的验证码:
一个简单的Go语言实现的验证码
https://github.com/lifei6671/gocaptcha
package main import ( "fmt" "html/template" "log" "net/http" "github.com/lifei6671/gocaptcha" ) // 项目中需要有 fonts ,tpl 目录 func main() { // 加载所有的字体 err := gocaptcha.ReadFonts("fonts",".ttf") if err != nil { fmt.Println("load fonts failed,err:",err) return } http.HandleFunc("/",Index) http.HandleFunc("/get/",Get) http.ListenAndServe(":9999",nil) } func Index(response http.ResponseWriter, request *http.Request) { t,err := template.ParseFiles("tpl/index.html") if err != nil { log.Fatal(err) } _ = t.Execute(response,nil) } const ( w = 250 // 验证码图片的宽 h = 100 // 验证码图片的高 ) func Get(response http.ResponseWriter, request *http.Request) { captchaImg := gocaptcha.NewCaptchaImage(w,h,gocaptcha.RandLightColor()) // 下面就在 captchaImg 这个对象 画各种东西了 err := captchaImg.DrawNoise(gocaptcha.CaptchaComplexLower). DrawTextNoise(gocaptcha.CaptchaComplexLower). DrawBorder(gocaptcha.ColorToRGB(0xDDA0DD)). DrawText("00oo"). DrawSineLine(). Error if err != nil { fmt.Println(err) } _ = captchaImg.SaveImage(response,gocaptcha.ImageFormatPng) }