From a829b5068dbbe4238c68bbce22888f6315c86abe Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Tue, 1 Nov 2016 17:11:01 -0700 Subject: [PATCH] go/gcimporter15: remove support for Go1.5 Change-Id: I183090131a675237be42cc005719554399704f8d Reviewed-on: https://go-review.googlesource.com/32541 Reviewed-by: Alan Donovan --- go/gcimporter15/bimport.go | 4 ++-- go/gcimporter15/exportdata.go | 4 ++-- go/gcimporter15/gcimporter.go | 6 +++--- go/gcimporter15/gcimporter_test.go | 4 ++-- go/gcimporter15/setname15.go | 31 ------------------------------ go/gcimporter15/setname16.go | 13 ------------- go/gcimporter15/setname_test.go | 28 --------------------------- 7 files changed, 9 insertions(+), 81 deletions(-) delete mode 100644 go/gcimporter15/setname15.go delete mode 100644 go/gcimporter15/setname16.go delete mode 100644 go/gcimporter15/setname_test.go diff --git a/go/gcimporter15/bimport.go b/go/gcimporter15/bimport.go index 03037a58..9bd9eb78 100644 --- a/go/gcimporter15/bimport.go +++ b/go/gcimporter15/bimport.go @@ -2,9 +2,9 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build go1.5 +// +build go1.6 -// This file is a copy of $GOROOT/src/go/internal/gcimporter/bimport.go, tagged for go1.5. +// This file is a copy of $GOROOT/src/go/internal/gcimporter/bimport.go, tagged for go1.6. package gcimporter diff --git a/go/gcimporter15/exportdata.go b/go/gcimporter15/exportdata.go index 988a45b7..b4b89d65 100644 --- a/go/gcimporter15/exportdata.go +++ b/go/gcimporter15/exportdata.go @@ -2,9 +2,9 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build go1.5 +// +build go1.6 -// This file is a copy of $GOROOT/src/go/internal/gcimporter/exportdata.go, tagged for go1.5. +// This file is a copy of $GOROOT/src/go/internal/gcimporter/exportdata.go, tagged for go1.6. // This file implements FindExportData. diff --git a/go/gcimporter15/gcimporter.go b/go/gcimporter15/gcimporter.go index 4f445f76..a0f9dfdf 100644 --- a/go/gcimporter15/gcimporter.go +++ b/go/gcimporter15/gcimporter.go @@ -2,9 +2,9 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build go1.5 +// +build go1.6 -// This file is a copy of $GOROOT/src/go/internal/gcimporter/gcimporter.go, tagged for go1.5, +// This file is a copy of $GOROOT/src/go/internal/gcimporter/gcimporter.go, tagged for go1.6, // and minimally adjusted to make it build. // Package gcimporter15 provides various functions for reading @@ -399,7 +399,7 @@ func (p *parser) getPkg(id, name string) *types.Package { // package exists already and we have an expected package name; // make sure names match or set package name if necessary if pname := pkg.Name(); pname == "" { - setName(pkg, name) + pkg.SetName(name) } else if pname != name { p.errorf("%s package name mismatch: %s (given) vs %s (expected)", id, pname, name) } diff --git a/go/gcimporter15/gcimporter_test.go b/go/gcimporter15/gcimporter_test.go index 7241215a..4e8f18bb 100644 --- a/go/gcimporter15/gcimporter_test.go +++ b/go/gcimporter15/gcimporter_test.go @@ -2,9 +2,9 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build go1.5 +// +build go1.6 -// This file is a copy of $GOROOT/src/go/internal/gcimporter/gcimporter_test.go, tagged for go1.5, +// This file is a copy of $GOROOT/src/go/internal/gcimporter/gcimporter_test.go, tagged for go1.6, // and minimally adjusted to make it build with code from (std lib) internal/testenv copied. package gcimporter diff --git a/go/gcimporter15/setname15.go b/go/gcimporter15/setname15.go deleted file mode 100644 index 8f78f540..00000000 --- a/go/gcimporter15/setname15.go +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2016 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. - -// +build go1.5,!go1.6 - -package gcimporter - -import ( - "go/types" - "unsafe" -) - -func setName(pkg *types.Package, name string) { - (*types_Package)(unsafe.Pointer(pkg)).name = name -} - -// The underlying type of types_Package is identical to -// the underlying type of types.Package. We use it with -// package unsafe to set the name field since 1.5 does -// not have the Package.SetName method. -// TestSetName verifies that the layout with respect to -// the name field is correct. -type types_Package struct { - path string - name string - scope *types.Scope - complete bool - imports []*types.Package - fake bool -} diff --git a/go/gcimporter15/setname16.go b/go/gcimporter15/setname16.go deleted file mode 100644 index d318e7c4..00000000 --- a/go/gcimporter15/setname16.go +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2016 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. - -// +build go1.6 - -package gcimporter - -import "go/types" - -func setName(pkg *types.Package, name string) { - pkg.SetName(name) -} diff --git a/go/gcimporter15/setname_test.go b/go/gcimporter15/setname_test.go deleted file mode 100644 index a8a33f7f..00000000 --- a/go/gcimporter15/setname_test.go +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2016 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. - -// +build go1.5 - -package gcimporter - -import ( - "go/types" - "testing" -) - -func TestSetName(t *testing.T) { - pkg := types.NewPackage("path", "foo") - scope := pkg.Scope() - - // verify setName - setName(pkg, "bar") - if name := pkg.Name(); name != "bar" { - t.Fatalf(`got package name %q; want "bar"`, name) - } - - // verify no other fields are changed - if pkg.Path() != "path" || pkg.Scope() != scope || pkg.Complete() || pkg.Imports() != nil { - t.Fatalf("setName changed other fields") - } -}