internal: remove pre-go1.12 conditionally compiled files
Change-Id: I496ad24654990341eae9508587e950abde05b540
Reviewed-on: https://go-review.googlesource.com/c/tools/+/404334
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Alan Donovan <adonovan@google.com>
diff --git a/internal/span/token.go b/internal/span/token.go
index 6f8b9b5..3fd2219 100644
--- a/internal/span/token.go
+++ b/internal/span/token.go
@@ -183,7 +183,7 @@
// at the end of the file, allowing for a trailing eol
return l.file.Size(), nil
}
- pos := lineStart(l.file, line)
+ pos := l.file.LineStart(line)
if !pos.IsValid() {
return -1, fmt.Errorf("line is not in file")
}
diff --git a/internal/span/token111.go b/internal/span/token111.go
deleted file mode 100644
index c41e94b..0000000
--- a/internal/span/token111.go
+++ /dev/null
@@ -1,40 +0,0 @@
-// Copyright 2019 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.12
-// +build !go1.12
-
-package span
-
-import (
- "go/token"
-)
-
-// lineStart is the pre-Go 1.12 version of (*token.File).LineStart. For Go
-// versions <= 1.11, we borrow logic from the analysisutil package.
-// TODO(rstambler): Delete this file when we no longer support Go 1.11.
-func lineStart(f *token.File, line int) token.Pos {
- // Use binary search to find the start offset of this line.
-
- min := 0 // inclusive
- max := f.Size() // exclusive
- for {
- offset := (min + max) / 2
- pos := f.Pos(offset)
- posn := f.Position(pos)
- if posn.Line == line {
- return pos - (token.Pos(posn.Column) - 1)
- }
-
- if min+1 >= max {
- return token.NoPos
- }
-
- if posn.Line < line {
- min = offset
- } else {
- max = offset
- }
- }
-}
diff --git a/internal/span/token112.go b/internal/span/token112.go
deleted file mode 100644
index 4c4dea1..0000000
--- a/internal/span/token112.go
+++ /dev/null
@@ -1,17 +0,0 @@
-// Copyright 2019 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.12
-// +build go1.12
-
-package span
-
-import (
- "go/token"
-)
-
-// TODO(rstambler): Delete this file when we no longer support Go 1.11.
-func lineStart(f *token.File, line int) token.Pos {
- return f.LineStart(line)
-}
diff --git a/internal/testenv/testenv.go b/internal/testenv/testenv.go
index 1d0cc3c..bfadb44 100644
--- a/internal/testenv/testenv.go
+++ b/internal/testenv/testenv.go
@@ -13,6 +13,7 @@
"io/ioutil"
"os"
"runtime"
+ "runtime/debug"
"strings"
"sync"
"time"
@@ -32,10 +33,19 @@
// packageMainIsDevel reports whether the module containing package main
// is a development version (if module information is available).
-//
-// Builds in GOPATH mode and builds that lack module information are assumed to
-// be development versions.
-var packageMainIsDevel = func() bool { return true }
+func packageMainIsDevel() bool {
+ info, ok := debug.ReadBuildInfo()
+ if !ok {
+ // Most test binaries currently lack build info, but this should become more
+ // permissive once https://golang.org/issue/33976 is fixed.
+ return true
+ }
+
+ // Note: info.Main.Version describes the version of the module containing
+ // package main, not the version of “the main module”.
+ // See https://golang.org/issue/33975.
+ return info.Main.Version == "(devel)"
+}
var checkGoGoroot struct {
once sync.Once
diff --git a/internal/testenv/testenv_112.go b/internal/testenv/testenv_112.go
deleted file mode 100644
index 4b6e57d..0000000
--- a/internal/testenv/testenv_112.go
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright 2019 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.12
-// +build go1.12
-
-package testenv
-
-import "runtime/debug"
-
-func packageMainIsDevelModule() bool {
- info, ok := debug.ReadBuildInfo()
- if !ok {
- // Most test binaries currently lack build info, but this should become more
- // permissive once https://golang.org/issue/33976 is fixed.
- return true
- }
-
- // Note: info.Main.Version describes the version of the module containing
- // package main, not the version of “the main module”.
- // See https://golang.org/issue/33975.
- return info.Main.Version == "(devel)"
-}
-
-func init() {
- packageMainIsDevel = packageMainIsDevelModule
-}