随笔分类 -  go

摘要:package main import ( "encoding/csv" "flag" "fmt" "io" "log" "net/http" "os" "strconv" "strings" "sync" "time" "golang.org/x/text/encoding/simplifiedc 阅读全文
posted @ 2025-11-04 23:13 卓能文 阅读(12) 评论(0) 推荐(0)
摘要:config.go: package main // 股票代码配置 - 简化版本,只包含主要指数和热门股票 var stockSymbols = []string{ // 主要指数 "sh000001", // 上证指数 "sh000016", // 上证50 "sh000300", // 沪深30 阅读全文
posted @ 2025-11-04 19:46 卓能文 阅读(13) 评论(0) 推荐(0)
摘要:package main import ( "encoding/json" "fmt" "io" "log" "net/http" "os" "time" ) // StockData 定义股票数据结构 type StockData struct { Symbol string `json:"sym 阅读全文
posted @ 2025-11-04 18:31 卓能文 阅读(16) 评论(0) 推荐(0)
摘要:package main import ( "encoding/csv" "encoding/json" "fmt" "io" "net/http" "os" "strconv" "strings" "time" "golang.org/x/text/encoding/simplifiedchine 阅读全文
posted @ 2025-11-04 15:23 卓能文 阅读(13) 评论(0) 推荐(0)
摘要:llgo A Go compiler based on LLVM export LLVM_CONFIG=/usr/bin/llvm-config export CGO_CPPFLAGS="$($LLVM_CONFIG --cppflags)" export CGO_CXXFLAGS=-std=c++ 阅读全文
posted @ 2025-06-22 09:03 卓能文 阅读(15) 评论(0) 推荐(0)
摘要:在某些情况下,您的应用程序并不需要 Redis,内部带有锁和过期机制的内存映射就足以满足需求。 例如,当您已知映射的大小且不需要存储大量数据时。适用场景包括 IP 速率限制或其他短期数据存储。 以下是如何在 Go 中实现这种数据结构,我们称之为 TTLMap: package ttlmap impo 阅读全文
posted @ 2025-05-22 14:02 卓能文 阅读(28) 评论(0) 推荐(0)
摘要:package main import ( "fmt" "io" "net/http" "os" "path/filepath" "regexp" ) const ( uploadDir = "./uploads" // 文件存储目录 maxUploadSize = 10 << 20 // 10MB 阅读全文
posted @ 2025-04-06 09:34 卓能文 阅读(17) 评论(0) 推荐(0)
摘要:unipdf internal/license/license.go: package license import ( "fmt" "time" "github.com/unidoc/unipdf/v3/common" ) func (licenseKey *LicenseKey) ToStrin 阅读全文
posted @ 2025-03-23 13:21 卓能文 阅读(44) 评论(0) 推荐(0)
摘要:package main import ( "time" _ "github.com/gogf/gf/contrib/nosql/redis/v2" // !!! important "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/net 阅读全文
posted @ 2025-03-05 20:27 卓能文 阅读(56) 评论(0) 推荐(0)
摘要:go install github.com/nao1215/gup@latest gup update 阅读全文
posted @ 2025-01-04 23:39 卓能文 阅读(49) 评论(0) 推荐(0)
摘要:package main import ( "context" "fmt" "log" "os" "github.com/joho/godotenv" "github.com/openai/openai-go" "github.com/openai/openai-go/option" ) func 阅读全文
posted @ 2024-11-28 17:42 卓能文 阅读(49) 评论(0) 推荐(0)
摘要:package main import ( "flag" "fmt" "github.com/carlmjohnson/versioninfo" ) func main() { fmt.Println("ShortInfo:", versioninfo.Short()) versioninfo.Ad 阅读全文
posted @ 2024-10-19 11:42 卓能文 阅读(18) 评论(0) 推荐(0)
摘要:原始地址:https://github.com/alarbada/htmx-stream window.htmx.defineExtension("stream", { onEvent: (name, evt) => { if (name "htmx:beforeRequest") { let el 阅读全文
posted @ 2024-10-16 18:38 卓能文 阅读(29) 评论(0) 推荐(0)
摘要:main.go: package main import ( "fmt" "net/http" "time" ) var indexHtml = `<!DOCTYPE html> <html> <body> <h1>SSE Messages</h1> <button id="stop">Stop</ 阅读全文
posted @ 2024-07-25 03:08 卓能文 阅读(60) 评论(0) 推荐(0)
摘要:package main import ( "bufio" "fmt" "log" "time" "github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2/middleware/cors" "github.com/valyala/fasth 阅读全文
posted @ 2024-07-23 12:11 卓能文 阅读(128) 评论(0) 推荐(0)
摘要:package main import ( "fmt" "time" "git.akyoto.dev/go/web" ) func main() { s := web.NewServer() // Static route s.Get("/", func(ctx web.Context) error 阅读全文
posted @ 2024-07-23 09:18 卓能文 阅读(23) 评论(0) 推荐(0)
摘要:package main import ( "embed" "io/fs" "net/http" ) //go:embed all:dist var assets embed.FS func Assets() (fs.FS, error) { return fs.Sub(assets, "dist" 阅读全文
posted @ 2024-07-17 22:47 卓能文 阅读(50) 评论(0) 推荐(0)
摘要:package main import ( "log" "os" "path/filepath" "github.com/unidoc/unioffice/document" "github.com/unidoc/unioffice/document/convert" ) func main() { 阅读全文
posted @ 2024-07-06 21:36 卓能文 阅读(336) 评论(0) 推荐(0)
摘要:package main import ( "log" "os" "path/filepath" ole "github.com/go-ole/go-ole" "github.com/go-ole/go-ole/oleutil" ) // NOTE: This example can only ru 阅读全文
posted @ 2024-07-06 19:10 卓能文 阅读(69) 评论(0) 推荐(0)
摘要:最近在玩openai,但opeanai的响应是一个漫长的过程,不能让浏览器端无限制等待,必须将openai的返回信息实时推送到客户端,让用户获得一个满意的交互过程。直接上源码: package chat import ( "context" "errors" "io" "os" "github.co 阅读全文
posted @ 2024-06-30 10:28 卓能文 阅读(98) 评论(0) 推荐(0)