Browse Source

Fix bootstrap with latest Go release (Go 1.13)

Also format all Go code with `gofmt`, and fix `go vet` warnings.

Fixes #906

Signed-off-by: Fazlul Shahriar <fshahriar@gmail.com>
Fazlul Shahriar 4 years ago
parent
commit
cfbdadc8a5

+ 3 - 3
bootstrap.sh

@@ -2,9 +2,9 @@
 
 echo Building the build tool...
 
-GOBIN="$(pwd)/util" GOPATH="$(pwd)/util/third_party:$(pwd)/util" go get -u github.com/Harvey-OS/ninep/cmd/ufs
-# GOBIN="$(pwd)/util" GOPATH="$(pwd)/util/third_party:$(pwd)/util" go get -f -u bldy.build/bldy
-GOBIN="$(pwd)/util" GOPATH="$(pwd)/util/third_party:$(pwd)/util" go get harvey/cmd/...
+GO111MODULE=on GOBIN="$(pwd)/util" go get -u github.com/Harvey-OS/ninep/cmd/ufs
+# GO111MODULE=on GOBIN="$(pwd)/util" go get -f -u bldy.build/bldy
+GO111MODULE=on GOBIN="$(pwd)/util" go get ./util/src/harvey/cmd/...
 
 
 # this will make booting a VM easier

+ 8 - 0
go.mod

@@ -0,0 +1,8 @@
+module github.com/Harvey-OS/harvey
+
+go 1.13
+
+require (
+	github.com/Harvey-OS/ninep v0.0.0-20190302184144-8010cab8eac9 // indirect
+	golang.org/x/crypto v0.0.0-20191002192127-34f69633bfdc
+)

+ 10 - 0
go.sum

@@ -0,0 +1,10 @@
+github.com/Harvey-OS/ninep v0.0.0-20190302184144-8010cab8eac9 h1:vcT+syCMklD8M/k/PcNYehmCRYrp8cyO7pjlZC1/vwg=
+github.com/Harvey-OS/ninep v0.0.0-20190302184144-8010cab8eac9/go.mod h1:YmLTajv/R+cjEsJ8/vfGOckeEBbz06tgHlYBSpbe+eo=
+golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
+golang.org/x/crypto v0.0.0-20191002192127-34f69633bfdc h1:c0o/qxkaO2LF5t6fQrT4b5hzyggAkLLlCUjqfRxd8Q4=
+golang.org/x/crypto v0.0.0-20191002192127-34f69633bfdc/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
+golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
+golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20190412213103-97732733099d h1:+R4KGOnez64A81RvjARKc4UT5/tI9ujCIVX+P5KiHuI=
+golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=

+ 8 - 6
sys/src/cmd/usb/usbd/m.go

@@ -1,3 +1,5 @@
+// +build ignore
+
 /*
  * This file is part of the UCB release of Plan 9. It is subject to the license
  * terms in the LICENSE file found in the top-level directory of this
@@ -20,15 +22,15 @@ import (
 )
 
 type Embed struct {
-	Name string
+	Name  string
 	Class string
-	CSP [4]string
-	VID string
-	DID string
+	CSP   [4]string
+	VID   string
+	DID   string
 }
 
 type SysConf struct {
-	Embeds  []Embed
+	Embeds []Embed
 }
 
 var outpath = flag.String("o", "", "path/to/output.c")
@@ -68,7 +70,7 @@ func main() {
 		log.Fatal(err)
 	}
 
-		tmpl, err := template.New("usbdb.c").Parse(`
+	tmpl, err := template.New("usbdb.c").Parse(`
 /* machine generated. do not edit */
 #include <u.h>
 #include <libc.h>

+ 4 - 4
sys/src/regress/_old/hello.go

@@ -1,18 +1,18 @@
 package main
 
 import (
-	"os"
 	"fmt"
+	"os"
 )
 
 func main() {
-	tab := []string{"0", "1", "2", "3", "4", "5", "6", "7", "8", "9" }
+	tab := []string{"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"}
 	ch := make(chan bool)
 	for i := 0; i < 10; i++ {
-		go func(i int){
+		go func(i int) {
 			fmt.Printf("hello %s fmt.printf %d/%d\n", tab[i], i, len(tab))
 			ch <- true
-		}(i);
+		}(i)
 	}
 	for i := 0; i < 10; i++ {
 		<-ch

+ 2 - 2
util/src/harvey/cmd/convert/convert.go

@@ -100,7 +100,7 @@ func removeempty(n string, jsmap map[string]interface{}) {
 
 func checkname(n string, jsmap map[string]interface{}) {
 	if _, ok := jsmap["Name"]; !ok {
-		log.Print("File %v has no \"Name\" key", n)
+		log.Printf("File %v has no \"Name\" key", n)
 	}
 }
 
@@ -178,7 +178,7 @@ func main() {
 		})
 
 		if err != nil {
-			log.Fatal("%v", err)
+			log.Fatalf("%v", err)
 
 		}
 	}

+ 13 - 13
util/src/harvey/cmd/mksys/mksys.go

@@ -26,7 +26,7 @@ OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+*/
 
 package main
 
@@ -65,12 +65,12 @@ type Bootmethods struct {
 	Name    string
 	Config  string
 	Connect string
-	Arg	string
+	Arg     string
 }
 
 type Sysconf struct {
-	Syscalls  []Syscall
-	Syserrors []Syserror
+	Syscalls    []Syscall
+	Syserrors   []Syserror
 	Bootmethods []Bootmethods
 }
 
@@ -200,7 +200,7 @@ TEXT runtime·{{ .Libname }}(SB),NOSPLIT,$0
 		a := os.Getenv("ARCH")
 		switch a {
 		case "aarch64":
-		tmpl, err = template.New("syscall.s").Parse(`/* automatically generated by mksys */
+			tmpl, err = template.New("syscall.s").Parse(`/* automatically generated by mksys */
 .globl	{{ .Libname }}
 {{ .Libname }}:
 	mov	x8, #{{ .Id }}
@@ -208,7 +208,7 @@ TEXT runtime·{{ .Libname }}(SB),NOSPLIT,$0
 	ret
 `)
 		case "amd64":
-		tmpl, err = template.New("syscall.s").Parse(`/* automatically generated by mksys */
+			tmpl, err = template.New("syscall.s").Parse(`/* automatically generated by mksys */
 .globl	{{ .Libname }}
 {{ .Libname }}:
 	movq %rcx, %r10 /* rcx gets smashed by systenter. Use r10.*/
@@ -216,20 +216,20 @@ TEXT runtime·{{ .Libname }}(SB),NOSPLIT,$0
 	syscall
 	ret
 `)
-		if err != nil {
-			log.Fatal(err)
-		}
+			if err != nil {
+				log.Fatal(err)
+			}
 		case "riscv":
-		tmpl, err = template.New("syscall.s").Parse(`/* automatically generated by mksys */
+			tmpl, err = template.New("syscall.s").Parse(`/* automatically generated by mksys */
 .globl	{{ .Libname }}
 {{ .Libname }}:
 	li a7, {{ .Id }}  /* Put the system call into a7 so we don't have to move a0-a6 around*/
 	scall
 	ret
 `)
-		if err != nil {
-			log.Fatal(err)
-		}
+			if err != nil {
+				log.Fatal(err)
+			}
 		default:
 			usage(a + " is not supported for system call generation.")
 		}

+ 2 - 2
util/src/harvey/cmd/preen/preen.go

@@ -100,7 +100,7 @@ func removeempty(n string, jsmap map[string]interface{}) {
 
 func checkname(n string, jsmap map[string]interface{}) {
 	if _, ok := jsmap["Name"]; !ok {
-		log.Print("File %v has no \"Name\" key", n)
+		log.Printf("File %v has no \"Name\" key", n)
 	}
 }
 
@@ -180,7 +180,7 @@ func main() {
 		})
 
 		if err != nil {
-			log.Fatal("%v", err)
+			log.Fatalf("%v", err)
 
 		}
 	}

+ 0 - 1
util/src/harvey/cmd/profile/profile.go

@@ -59,7 +59,6 @@ type Record struct {
 	pcs []pc
 }
 
-
 type Symbol struct {
 	Addr uint64
 	Name string