Skip to content

Commit fb44169

Browse files
committed
+go
1 parent 0b89be6 commit fb44169

File tree

6 files changed

+81
-0
lines changed

6 files changed

+81
-0
lines changed

projects/go.dev/build.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { BuildOptions, unarchive } from "brewkit";
2+
3+
export default async function ({ prefix, tag }: BuildOptions) {
4+
const arch = (() => {
5+
switch (`${Deno.build.os}/${Deno.build.arch}`) {
6+
case "darwin/x86_64":
7+
return "darwin-amd64.tar.gz";
8+
case "linux/x86_64":
9+
return "linux-amd64.tar.gz";
10+
case "windows/x86_64":
11+
return "windows-amd64.zip";
12+
case "linux/aarch64":
13+
return "linux-arm64.tar.gz";
14+
case "darwin/aarch64":
15+
return "darwin-arm64.tar.gz";
16+
default:
17+
throw new Error("Unsupported platform");
18+
}
19+
})();
20+
21+
prefix.mkdir('p').cd();
22+
await unarchive(`https://go.dev/dl/go${tag}.${arch}`);
23+
}

projects/go.dev/fixup.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { Path } from "brewkit";
2+
3+
export default function (path: Path) {
4+
// stripping fails for plenty of stuff in `src`
5+
if (path.components().includes("src")) return false;
6+
// these go binaries are ”not dynamic executables” and thus `ldd` fails to inspect them!
7+
if (path.parent().basename() == "bin") return false;
8+
if (path.basename() == "doc") return false;
9+
if (path.string.includes("pkg/tool/linux_")) return false;
10+
return true;
11+
}

projects/go.dev/package.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name:
2+
Go
3+
4+
repository:
5+
https://github.com/golang/go
6+
7+
programs:
8+
- bin/go
9+
- bin/gofmt
10+
11+
linux:
12+
dependencies:
13+
curl.se/ca-certs: '*'
14+
15+
platforms:
16+
- darwin/aarch64
17+
- darwin/x86-64
18+
- linux/aarch64
19+
- linux/x86-64
20+
- windows/x86-64

projects/go.dev/test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package main
2+
import "fmt"
3+
func main() {
4+
fmt.Println("Hello World")
5+
}

projects/go.dev/test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { backticks, run } from "brewkit";
2+
import { assertEquals } from "jsr:@std/assert@1/equals";
3+
4+
export default async function() {
5+
assertEquals(await backticks`go run test.go`, "Hello World");
6+
7+
run`go build -o test test.go`;
8+
assertEquals(await backticks`./test`, "Hello World");
9+
}

projects/go.dev/versions.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { github, semver } from "brewkit";
2+
3+
export default async function () {
4+
return (await github.tags("golang/go")).compact(
5+
({ name: tag }) => {
6+
tag = tag.replace(/^go/, "");
7+
const version = semver.parse(tag);
8+
if (version) {
9+
return { tag, version };
10+
}
11+
},
12+
);
13+
}

0 commit comments

Comments
 (0)