go1.12 发行说明

February 27, 2019

Go1.12 概述

Go1.12是目前最新的Go版本,在Go1.11发行之后的六个月到来,大多数的改变是工具链、运行时和包,总的来说,该版本依然保持了Go1兼容性承诺,希望大多数的程序还能和以前一样继续的编译和运行。

语言上的改变

语言规范上是没有改变的。

部分

  • 竞争检测现在是支持在linux/arm64
  • Go1.12是最后一个支持FreeBSD 10.x的版本,Go1.13将开始支持FreeBSD 11.2+ or FreeBSD 12.0+, FreeBSD 12.0+要求设置一个COMPAT_FREEBSD11的变量,这是默认设置的。
  • linux/ppc64上支持cgo

Windows

windows/arm的部分支持gowindows10 lot的32位物联网arm芯片上,比如树莓派3.

AIX

Go现在支持AIX 7.2及更高版本的POWER8体系结构(aix / ppc64)。尚不支持外部链接,cgo,pprof和竞赛检测器

Darwin

Go 1.12是最后一个支持运行在macOS 10.10系统之上的版本,Go1.13将要求操作系统必须是macOS 10.11以上。

工具

go tool vet 不再支持

go vet命令将不在支持,关于这部分功能迁移到了analysis工具中,更多详情查看包golang.org/x/tools/go/analysis,使用方式有所改变,不能再使用go tool vet此命令,需要更改为go vet命令,使用go vet可以支持所以的版本。 -shadow将不再可用,需要替换。

go get -u golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow
go vet -vettool=$(which shadow)

Tour将不在默认安装

Go Tour不会包含再主要的包中,如果需要使用需要自行安装。

go get -u golang.org/x/tour
tour

Build cache 要求

如果设置了GOCACHE=off将导致go命令行写缓存失败。

二进制包

Go 1.12是最后一个支持二进制包的版本.

Cgo

Go1.12C语言的EGLDisplay类型翻译为gouintptr类型。更多信息请参考cgo 文档

核心库

TLS1.3

Go1.12添加了对TLS 1.3的支持,可以通过设置环境变量tls13=1GODEBUG来启用,在Go1.13版本中将默认开启。

bufio

如果在调用完Peek方法之后调用UnreadRune and UnreadByte将会返回一个错误。

bytes

func ReplaceAll(s, old, new []byte) []byte

新函数ReplaceAll将返回一个字节切片的副本。s是原字节,old是匹配字节,new是替换为新的字符。


package main

import (
	"bytes"
	"fmt"
)

func main() {
	fmt.Printf("%s\n", bytes.ReplaceAll([]byte("oink oink oink"), []byte("oink"), []byte("moo")))
	fmt.Printf("%s\n",bytes.ReplaceAll([]byte("this is a demo,place open the demo file"),[]byte("demo"),[]byte("test")))
}
//输出
moo moo moo
this is a test,place open the test file

crypto/rand

Reader.Read如果超过60s还没有读取到熵,那么将会打印输出。

crypto/rc4

这个版本移除了其他版本的实现,只保留了Go版本。 RC4是一种流加密算法

crypto/tls

如果客户端发送的初始消息看起来不像TLS,则服务器将不再使用警报进行回复,当TLS记录头无效时,返回RecordHeaderError.

type RecordHeaderError struct {
        // Msg contains a human readable string that describes the error.
        Msg string
        // RecordHeader contains the five bytes of TLS record header that
        // triggered the error.
        RecordHeader [5]byte
        // Conn provides the underlying net.Conn in the case that a client
        // sent an initial handshake that didn't look like TLS.
        // It is nil if there's already been a handshake or a TLS alert has
        // been written to the connection.
        Conn net.Conn // Go 1.12
}

database/sql

现在可以通过将*Rows值传递给Row.Scan方法来获取查询光标.

expvar

Delete方法运行删除一个Map类型的的key.

func (v *Map) Delete(key string)

lib/time

当操作系统未提供时区数据时,将会使用配置的$GOROOT/lib/time/zoneinfo.zip数据。

参考官方


LRF 记录学习、生活的点滴