cmd/godex: handle printing of type aliases

Also: remove go1.5 build tags (x/tools requires Go 1.6 or higher).

For golang/go#18130.

Change-Id: I3d9deee9e87d8794b2884281c0bb53caa5ed6221
Reviewed-on: https://go-review.googlesource.com/35106
Reviewed-by: Alan Donovan <adonovan@google.com>
diff --git a/cmd/godex/gc.go b/cmd/godex/gc.go
index 66b0a0e..95eba65 100644
--- a/cmd/godex/gc.go
+++ b/cmd/godex/gc.go
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build go1.5
-
 // This file implements access to gc-generated export data.
 
 package main
diff --git a/cmd/godex/gccgo.go b/cmd/godex/gccgo.go
index 785441c..7644998 100644
--- a/cmd/godex/gccgo.go
+++ b/cmd/godex/gccgo.go
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build go1.5
-
 // This file implements access to gccgo-generated export data.
 
 package main
diff --git a/cmd/godex/godex.go b/cmd/godex/godex.go
index 5d40d87..a222ed63 100644
--- a/cmd/godex/godex.go
+++ b/cmd/godex/godex.go
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build go1.5
-
 package main
 
 import (
diff --git a/cmd/godex/isAlias18.go b/cmd/godex/isAlias18.go
new file mode 100644
index 0000000..cab1292
--- /dev/null
+++ b/cmd/godex/isAlias18.go
@@ -0,0 +1,13 @@
+// Copyright 2017 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.9
+
+package main
+
+import "go/types"
+
+func isAlias(obj *types.TypeName) bool {
+	return false // there are no type aliases before Go 1.9
+}
diff --git a/cmd/godex/isAlias19.go b/cmd/godex/isAlias19.go
new file mode 100644
index 0000000..6ebdd42
--- /dev/null
+++ b/cmd/godex/isAlias19.go
@@ -0,0 +1,13 @@
+// Copyright 2017 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.9
+
+package main
+
+import "go/types"
+
+func isAlias(obj *types.TypeName) bool {
+	return obj.IsAlias()
+}
diff --git a/cmd/godex/print.go b/cmd/godex/print.go
index 02b4606..adce864 100644
--- a/cmd/godex/print.go
+++ b/cmd/godex/print.go
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build go1.5
-
 package main
 
 import (
@@ -143,7 +141,13 @@
 	p.printDecl("type", len(typez), func() {
 		for _, obj := range typez {
 			p.printf("%s ", obj.Name())
-			p.writeType(p.pkg, obj.Type().Underlying())
+			typ := obj.Type()
+			if isAlias(obj) {
+				p.print("= ")
+				p.writeType(p.pkg, typ)
+			} else {
+				p.writeType(p.pkg, typ.Underlying())
+			}
 			p.print("\n")
 		}
 	})
diff --git a/cmd/godex/source.go b/cmd/godex/source.go
index 0d3c006..85235e9 100644
--- a/cmd/godex/source.go
+++ b/cmd/godex/source.go
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build go1.5
-
 // This file implements access to export data from source.
 
 package main
diff --git a/cmd/godex/writetype.go b/cmd/godex/writetype.go
index ed0bd9f..dd17f90 100644
--- a/cmd/godex/writetype.go
+++ b/cmd/godex/writetype.go
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build go1.5
-
 // This file implements writing of types. The functionality is lifted
 // directly from go/types, but now contains various modifications for
 // nicer output.