mirror of https://github.com/golang/go.git
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>
This commit is contained in:
parent
45c8a71312
commit
0ebacc111e
|
|
@ -183,7 +183,7 @@ func (l *FileConverter) ToOffset(line, col int) (int, error) {
|
|||
// 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")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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)
|
||||
}
|
||||
|
|
@ -13,6 +13,7 @@ import (
|
|||
"io/ioutil"
|
||||
"os"
|
||||
"runtime"
|
||||
"runtime/debug"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
|
@ -32,10 +33,19 @@ type helperer interface {
|
|||
|
||||
// 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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
Loading…
Reference in New Issue