1 .1.2 - d e s 4 1.2.2 - 1.2 r d! 4 4-5.2.2 - F 2 - M E - S G 4 6.2.2 - u o'G - 1.2 o ! ... 4 1 .2.2 - 1.2 .1 4 1 .2.2 - T #2 - W 's e 1.2 4 2 .2.2 - u m ;-) L v P c (P S ) - @a @h r .i - M P #1 , 2 .2. 2 2
in func SumIntsOrFloats[K comparable, V int64 | float64](m map[K]V) V { var s V for _, v := range m { s += v } return s } 4 N s y c b interface{}, l r u p r ! L v P c (P S ) - @a @h r .i - M P #1 , 2 .2. 2 5
ra s 1.1 slice := []int{1,2,3, 4} array := (*[4]byte)(slice) s 1.2 slice := []int{1,2,3, 4} array := [4](slice) L v P c (P S ) - @a @h r .i - M P #1 , 2 .2. 2 6
func main() { now := time.Now() now.Format("2006-02-01") fmt.Println(now) } $ go vet main.go # command-line-arguments ./main.go:10:14: 2006-02-01 should be 2006-01-02 L v P c (P S ) - @a @h r .i - M P #1 , 2 .2. 2 8
s go tool covdata <mode> -i=<dir1,dir2,...> ...flags... go tool covdata percent -i=somedata go tool covdata merge -i=windows_datadir,macos_datadir -o merged L v P c (P S ) - @a @h r .i - M P #1 , 2 .2. 2 1
T e crypto/ecdh p p s e t s o E c C D e-H e e e e S c n C 5 . 4 T e f n e .J r e w g s e w a o d a h e p i n h Unwrap() []error m . 4 T e http.ResponseController p p s a e d p - r f n o h h http.ResponseWriter i c . 4 T httputil.ReverseProxy f i p i s e R o f n, s d h p s D r h . L v P c (P S ) - @a @h r .i - M P #1 , 2 .2. 2 1
4 T e context.WithCancelCause f n p s a c a c t a g e . a e a r e b c h e context.Cause f n. 4 T e os/exec.Cmd e C n W a s h b r h m e t a t C c d i p e . 4 I time p e a e e c t DateTime, DateOnly n TimeOnly L v P c (P S ) - @a @h r .i - M P #1 , 2 .2. 2 1
%w ...", ..., err, ...) if errors.Is(err, fs.ErrExist) err1 := errors.New("err1") err2 := errors.New("err2") err := errors.Join(err1, err2) L v P c (P S ) - @a @h r .i - M P #1 , 2 .2. 2 1
r *Request) { rc := http.NewResponseController(w) rc.SetWriteDeadline(time.Time{}) // disable Server.WriteTimeout when sending a large response io.Copy(w, bigData) } 4 G I : n /h : a m a t s H L v P c (P S ) - @a @h r .i - M P #1 , 2 .2. 2 1
func(r *httputil.ProxyRequest) { r.SetURL(outboundURL) // Forward request to outboundURL. r.SetXForwarded() // Set X-Forwarded-* headers. r.Out.Header.Set("X-Additional-Header", "header set by the proxy") }, } 4 T e R e s e h i g r f h o g r n d a e h m t k e w a s f i p . L v P c (P S ) - @a @h r .i - M P #1 , 2 .2. 2 1
cancel := context.WithCancelCause(parent) cancel(myError) ctx.Err() // returns context.Canceled context.Cause(ctx) // returns myError L v P c (P S ) - @a @h r .i - M P #1 , 2 .2. 2 1
cancel() if err := exec.CommandContext(ctx, "sleep", "5").Run(); err != nil { // This will fail after 100 milliseconds. The 5 second sleep // will be interrupted. } 4 T e m e Cancel n WaitDelay s h b r o h m e t a t C c d t p e t I/O p s l e a c p . L v P c (P S ) - @a @h r .i - M P #1 , 2 .2. 2 1
"https://github.com" str, ok := strings.CutPrefix(s, "https://") if ok { fmt.Println(str) } else { fmt.Println(s) } L v P c (P S ) - @a @h r .i - M P #1 , 2 .2. 2 2
p r g a r 1.2 4 h ://b .c h .n /p /2 /g -1 -l e- c / 4 h ://b .c h .n /p /2 /g -1 -a - e -r e l / 4 h ://b .c h .n /p /2 /g -1 -m - f s/ L v P c (P S ) - @a @h r .i - M P #1 , 2 .2. 2 2