aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/api
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2020-07-06 09:49:20 -0400
committerRuss Cox <rsc@golang.org>2020-10-20 02:32:41 +0000
commitd4da735091986868015369e01c63794af9cc9b84 (patch)
tree4f23c46dc0786122d9d8883f1dfb8003c514909e /src/cmd/api
parent627959eb04ee0edc4a985a7526ed7fe838ad2573 (diff)
downloadgo-d4da735091986868015369e01c63794af9cc9b84.tar.gz
go-d4da735091986868015369e01c63794af9cc9b84.zip
io/fs: move FileInfo, FileMode, PathError, ErrInvalid, ... from os to io/fs
First step of creating the new io/fs package. For #41190. Change-Id: I1339b1abdd533b0f1deab283628088b2f706fb5b Reviewed-on: https://go-review.googlesource.com/c/go/+/243906 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Rob Pike <r@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Diffstat (limited to 'src/cmd/api')
-rw-r--r--src/cmd/api/goapi.go20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/cmd/api/goapi.go b/src/cmd/api/goapi.go
index 6a80ed269b..b14d57c236 100644
--- a/src/cmd/api/goapi.go
+++ b/src/cmd/api/goapi.go
@@ -326,6 +326,18 @@ func compareAPI(w io.Writer, features, required, optional, exception []string, a
return
}
+// aliasReplacer applies type aliases to earlier API files,
+// to avoid misleading negative results.
+// This makes all the references to os.FileInfo in go1.txt
+// be read as if they said fs.FileInfo, since os.FileInfo is now an alias.
+// If there are many of these, we could do a more general solution,
+// but for now the replacer is fine.
+var aliasReplacer = strings.NewReplacer(
+ "os.FileInfo", "fs.FileInfo",
+ "os.FileMode", "fs.FileMode",
+ "os.PathError", "fs.PathError",
+)
+
func fileFeatures(filename string) []string {
if filename == "" {
return nil
@@ -334,7 +346,9 @@ func fileFeatures(filename string) []string {
if err != nil {
log.Fatalf("Error reading file %s: %v", filename, err)
}
- lines := strings.Split(string(bs), "\n")
+ s := string(bs)
+ s = aliasReplacer.Replace(s)
+ lines := strings.Split(s, "\n")
var nonblank []string
for _, line := range lines {
line = strings.TrimSpace(line)
@@ -856,6 +870,10 @@ func (w *Walker) emitObj(obj types.Object) {
func (w *Walker) emitType(obj *types.TypeName) {
name := obj.Name()
typ := obj.Type()
+ if obj.IsAlias() {
+ w.emitf("type %s = %s", name, w.typeString(typ))
+ return
+ }
switch typ := typ.Underlying().(type) {
case *types.Struct:
w.emitStructType(name, typ)