Opened 8 months ago

Last modified 8 months ago

#69466 new request

Add Go 1.22.0 port

Reported by: programmingkidx Owned by:
Priority: Normal Milestone:
Component: ports Version:
Keywords: go Cc: ci42, herbygillot (Herby Gillot)
Port:

Description

Hi, I ask that a Go 1.22.0 port be made. Currently there is a go port but the word go is very vague. I believe it would better if we used the version in the name just like we do for clang. With clang we have the version appended to the name like this: clang-8.0, clang-9.0. This would make things much clearer for the user.

Go 1.22.0 is the newest version of Go as of this date and would like to see it be installed on Mac OS 10.12. The official system requirements require Mac OS 10.13 or higher but I was able to install it using a patch.

Here are my directions on how to build Go 1.22.0 on Mac OS 10.12:

Open the Terminal application.
Install Go 1.17 thru MacPorts: sudo port install go
Download the Go source code: git clone https://github.com/golang/go.git
cd go
cd src

Download Go 1.20: git checkout tags/go1.20.14. You should see a "go" folder appear.

Apply patch Fix-go-1.20-to-build-on-Mac-OS-10.12.patch: patch -p2 < <patch path>.
You should see this output:
patching file crypto/x509/internal/macos/security.go
patching file make.bash
patching file syscall/syscall_bsd.go
patching file syscall/syscall_darwin.go
patching file syscall/zsyscall_darwin_amd64.go

Note: If you see an error about not finding a file you may have skipped a step. Be sure to be in the src folder in the Terminal. 

Build Go 1.20: ./make.bash or ./all.bash for tests at the end (not all tests pass, this is ok).
Make a copy of the go folder and place it somewhere safe. I would rename it to "go1.20".
Add the path of the bin folder (inside the go1.20 folder) to the PATH variable: PATH="<bin folder path>":$PATH
Type "go version" run it. You should see this: "go version go1.20.14 darwin/amd64". If you see another version then the PATH variable might not be set correctly. Be sure the path you added has "bin" at the end.

Reset the local repo: "git reset --hard". You should see this message: HEAD is now at 90a870f1dc [release-branch.go1.20] go1.20.14.
Download Go 1.22.0: git checkout go1.22.0
Apply patch: patch -p2 < Make-building-go-1.22.0-work-on-Mac-OS-10.12 v4.patch
You should see this message:
patching file all.bash
patching file cmd/api/main_test.go
patching file cmd/go/terminal_test.go
patching file cmd/gofmt/gofmt_unix_test.go
patching file crypto/x509/internal/macos/security.go
patching file crypto/x509/platform_test.go
patching file internal/syscall/unix/asm_darwin.s
patching file internal/syscall/unix/pty_darwin.go
patching file internal/testpty/pty_darwin.go
patching file net/http/client_test.go
patching file os/signal/signal_cgo_test.go
patching file syscall/syscall_bsd.go
patching file syscall/syscall_darwin.go
patching file syscall/syscall_darwin_amd64.go
patching file syscall/zsyscall_darwin_amd64.go
patching file syscall/zsyscall_darwin_amd64.s

Build the compiler: ./make.bash or ./all.bash for tests.
To use this compiler you can set the PATH variable to point to the bin folder like we did for Go 1.20.

Here is a small test program you can run to see if your compiler works. Save this code to a file called newfeatures.go. Then you can run it like this: go run newfeatures.go

// A program to test some of the new features of Go 1.22

package main

import "fmt"
import "slices"
import "math/rand/v2"

func main() {
	fmt.Println("Testing some new features in Go 1.22")

	// range over a number
	fmt.Print("range: ")
	for x := range 10 {
		fmt.Printf("%d,", x)
	}
	fmt.Println("")
	
	// slices.Concat()
	slice1 := []int{1,2,3}
	slice2 := []int{4,5,6}
	slice3 := slices.Concat(slice1, slice2)
	fmt.Println("slices.Concat():", slice3)

	// new rand.N() function	
	var maxRand uint = 100
	fmt.Println("rand/v2:", rand.N(maxRand))	
}

Attachments (2)

Fix-go-1.20-to-build-on-Mac-OS-10.12.patch (4.5 KB) - added by programmingkidx 8 months ago.
Make-building-go-1.22.0-work-on-Mac-OS-10.12 v4.patch (12.2 KB) - added by programmingkidx 8 months ago.

Download all attachments as: .zip

Change History (3)

Changed 8 months ago by programmingkidx

Changed 8 months ago by programmingkidx

comment:1 Changed 8 months ago by jmroot (Joshua Root)

Cc: ci42 herbygillot added
Note: See TracTickets for help on using tickets.