A golang ebook intro how to build a web with golang
BSD 3-Clause "New" or "Revised" License
41256
2432
10668

image

Hi, In chapter 3.3, the src.Server should be srv.Server right?

文件格式都是 数字.md 格式,回头在看找某个知识点的时候很不方便,希望文件格式添加内容标题,比如:01.0-环境配置.md

func (manager *Manager) GC() {
	manager.lock.Lock()
	defer manager.lock.Unlock()
	time.AfterFunc(time.Duration(manager.maxLifeTime), func() { manager.provider.SessionGC(manager.maxLifeTime) })
}

time.AfterFunc第一个时间参数的单位是纳秒,根据上下文信息,这里是否应该乘上time.Second,如下所示

func (manager *Manager) GC() {
	manager.lock.Lock()
	defer manager.lock.Unlock()
	time.AfterFunc(time.Duration(manager.maxLifeTime)*time.Second, func() { manager.provider.SessionGC(manager.maxLifeTime) })
}

GOPATH is worked after execute command 'go env -w GO111MODULE=off'

方法里最后一个 break 是不是改为 continue?

func (pder *Provider) SessionGC(maxlifetime int64) {
	pder.lock.Lock()
	defer pder.lock.Unlock()

	for {
		element := pder.list.Back()
		if element == nil {
			break
		}
		if (element.Value.(*SessionStore).timeAccessed.Unix() + maxlifetime) < time.Now().Unix() {
			pder.list.Remove(element)
			delete(pder.sessions, element.Value.(*SessionStore).sid)
		} else {
			break
		}
	}
}

It seems Gitbook has removed all traces of the pdf/epub

WebAssembly?

Go的html/template包默认帮你过滤了html标签,但是有时候你只想要输出这个<script>alert()</script>看起来正常的信息,该怎么处理?请使用text/template。请看下面的例子:

import "text/template"
...
t, err := template.New("foo").Parse(`{{define "T"}}Hello, {{.}}!{{end}}`)
err = t.ExecuteTemplate(out, "T", "<script>alert('you have been pwned')</script>")

改为如下代码可直接运行得到输出

import (
	"text/template"
	"os"
)
t, _ := template.New("foo").Parse(`{{define "T"}}Hello, {{.}}!{{end}}`)
t.ExecuteTemplate(os.Stdout, "T", "<script>alert('you have been pwned')</script>")

Thank you for creating this resource, I've found it tremendously useful.

---Ideas and implications of standard store website---

请大佬们看一眼gitbook

大佬你好,请问这个有纸质书本出售吗?

Slim...sleek design and feel free to play around with 3d as well...