1
0
mirror of https://github.com/golang/go synced 2024-11-06 10:36:13 -07:00

all: update build tags to require/assume Go 1.20

Updates #54265.

Change-Id: Ia1c9486484c73c565bb4f78234dedff6d929ed42
Reviewed-on: https://go-review.googlesource.com/c/go/+/511656
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
This commit is contained in:
Matthew Dempsky 2023-07-20 11:41:04 -07:00 committed by Gopher Robot
parent 9ceba95008
commit 82ee946d7a
14 changed files with 15 additions and 139 deletions

View File

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || (solaris && go1.20)
//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris
package base

View File

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build !aix && !darwin && !dragonfly && !freebsd && !linux && !netbsd && !openbsd && !(solaris && go1.20)
//go:build !aix && !darwin && !dragonfly && !freebsd && !linux && !netbsd && !openbsd && !solaris
package base

View File

@ -2,9 +2,6 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build go1.19
// +build go1.19
package main
import (

View File

@ -1,47 +0,0 @@
// Copyright 2021 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build !go1.19
// +build !go1.19
package main
import (
"os"
"os/exec"
"strings"
)
// setDir sets cmd.Dir to dir, and also adds PWD=dir to cmd's environment.
func setDir(cmd *exec.Cmd, dir string) {
cmd.Dir = dir
setEnv(cmd, "PWD", dir)
}
// setEnv sets cmd.Env so that key = value.
func setEnv(cmd *exec.Cmd, key, value string) {
kv := key + "=" + value
if cmd.Env == nil {
cmd.Env = os.Environ()
}
cmd.Env = append(cmd.Env, kv)
}
// unsetEnv sets cmd.Env so that key is not present in the environment.
func unsetEnv(cmd *exec.Cmd, key string) {
if cmd.Env == nil {
cmd.Env = os.Environ()
}
prefix := key + "="
newEnv := []string{}
for _, entry := range cmd.Env {
if strings.HasPrefix(entry, prefix) {
continue
}
newEnv = append(newEnv, entry)
// key may appear multiple times, so keep going.
}
cmd.Env = newEnv
}

View File

@ -2,13 +2,13 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Go 1.20 and later requires Go 1.17 as the bootstrap toolchain.
// Go 1.22 and later requires Go 1.20 as the bootstrap toolchain.
// If cmd/dist is built using an earlier Go version, this file will be
// included in the build and cause an error like:
//
// % GOROOT_BOOTSTRAP=$HOME/sdk/go1.16 ./make.bash
// Building Go cmd/dist using /Users/rsc/sdk/go1.16. (go1.16 darwin/amd64)
// found packages main (build.go) and building_Go_requires_Go_1_17_13_or_later (notgo117.go) in /Users/rsc/go/src/cmd/dist
// found packages main (build.go) and building_Go_requires_Go_1_20_6_or_later (notgo120.go) in /Users/rsc/go/src/cmd/dist
// %
//
// which is the best we can do under the circumstances.
@ -16,7 +16,7 @@
// See go.dev/issue/44505 for more background on
// why Go moved on from Go 1.4 for bootstrap.
//go:build !go1.17
// +build !go1.17
//go:build !go1.20
// +build !go1.20
package building_Go_requires_Go_1_17_13_or_later
package building_Go_requires_Go_1_20_6_or_later

View File

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || (solaris && go1.20)
//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris
package bio

View File

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build !aix && !darwin && !dragonfly && !freebsd && !linux && !netbsd && !openbsd && !(solaris && go1.20)
//go:build !aix && !darwin && !dragonfly && !freebsd && !linux && !netbsd && !openbsd && !solaris
package bio

View File

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build darwin && go1.20
//go:build darwin
package ld

View File

@ -1,24 +0,0 @@
// Copyright 2022 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build darwin && !go1.20
package ld
import (
"syscall"
"unsafe"
)
func msync(b []byte, flags int) (err error) {
var p unsafe.Pointer
if len(b) > 0 {
p = unsafe.Pointer(&b[0])
}
_, _, errno := syscall.Syscall(syscall.SYS_MSYNC, uintptr(p), uintptr(len(b)), uintptr(flags))
if errno != 0 {
return errno
}
return nil
}

View File

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || (solaris && go1.20)
//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris
package ld

View File

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build !aix && !darwin && !dragonfly && !freebsd && !linux && !netbsd && !openbsd && !(solaris && go1.20) && !windows
//go:build !aix && !darwin && !dragonfly && !freebsd && !linux && !netbsd && !openbsd && !solaris && !windows
package ld

View File

@ -179,7 +179,7 @@ func (t *Type) IsDirectIface() bool {
}
func (t *Type) GcSlice(begin, end uintptr) []byte {
return unsafeSliceFor(t.GCData, int(end))[begin:]
return unsafe.Slice(t.GCData, int(end))[begin:]
}
// Method on non-interface type
@ -660,7 +660,7 @@ func (n Name) Name() string {
return ""
}
i, l := n.ReadVarint(1)
return unsafeStringFor(n.DataChecked(1+i, "non-empty string"), l)
return unsafe.String(n.DataChecked(1+i, "non-empty string"), l)
}
// Tag returns the tag string for n, or empty if there is none.
@ -670,7 +670,7 @@ func (n Name) Tag() string {
}
i, l := n.ReadVarint(1)
i2, l2 := n.ReadVarint(1 + i + l)
return unsafeStringFor(n.DataChecked(1+i+l+i2, "non-empty string"), l2)
return unsafe.String(n.DataChecked(1+i+l+i2, "non-empty string"), l2)
}
func NewName(n, tag string, exported, embedded bool) Name {

View File

@ -1,32 +0,0 @@
// Copyright 2023 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build !go1.20
// +build !go1.20
package abi
import "unsafe"
type (
stringHeader struct {
Data *byte
Len int
}
sliceHeader struct {
Data *byte
Len int
Cap int
}
)
func unsafeStringFor(b *byte, l int) string {
h := stringHeader{Data: b, Len: l}
return *(*string)(unsafe.Pointer(&h))
}
func unsafeSliceFor(b *byte, l int) []byte {
h := sliceHeader{Data: b, Len: l, Cap: l}
return *(*[]byte)(unsafe.Pointer(&h))
}

View File

@ -1,18 +0,0 @@
// Copyright 2023 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build go1.20
// +build go1.20
package abi
import "unsafe"
func unsafeStringFor(b *byte, l int) string {
return unsafe.String(b, l)
}
func unsafeSliceFor(b *byte, l int) []byte {
return unsafe.Slice(b, l)
}