随笔分类 - golang
Go 是一个开源的编程语言,它能让构造简单、可靠且高效的软件变得容易
go 模板引擎
摘要:go 内置的模板引擎库text/template,在实际开发中一般用的是html/template package main import ( "fmt" "os" "text/template" ) func main() { tmpl := `This is the first template
阅读全文
go main中调用其他文件的变量或方法
摘要:场景 1:调用同一 main 包内其他文件的成员 如果其他文件也声明为 package main(同属一个可执行程序),可以直接访问其中的成员(无论是否大写,但建议大写规范) 目录结构: myproject/ ├── main.go └── helper.go # 同属 main 包 // help
阅读全文
golang 构建Web服务器
摘要:main.go package main import ( "fmt" "log" "net/http" ) func loggingMiddleware(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.Re
阅读全文
go template 使用
摘要:test.html <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Go Web</title> </head> <body> {{ .
阅读全文
go 实现一个简单的web服务
摘要:package main import ( "fmt" "log" "net/http" "strings" ) func sayhelloName(w http.ResponseWriter, r *http.Request) { r.ParseForm() //解析参数,默认是不会解析的 fmt
阅读全文
Go 语言环境安装
摘要:下载 https://golang.google.cn/dl/。 linux下安装 1、下载二进制包:go1.4.linux-amd64.tar.gz。 2、将下载的二进制包解压至 /usr/local目录。 tar -C /usr/local -xzf go1.4.linux-amd64.tar.
阅读全文
浙公网安备 33010602011771号