Skip to content

Update to go 1.19 #644

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Dec 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/calm-cobras-tie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/compiler': patch
---

Update Go to 1.19
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// Update the VARIANT arg to pick a version of Go: 1, 1.16, 1.17
// Append -bullseye or -buster to pin to an OS version.
// Use -bullseye variants on local arm64/Apple Silicon.
"VARIANT": "1.17",
"VARIANT": "1.19",
// Options
"NODE_VERSION": "16"
}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17
go-version: 1.19

- name: Test
run: go test -v ./internal/...
Expand All @@ -36,7 +36,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17
go-version: 1.19

- name: Set up PNPM
uses: pnpm/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17
go-version: 1.19

- name: Set up PNPM
uses: pnpm/[email protected]
Expand Down
6 changes: 3 additions & 3 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ issues:

- linters:
- typecheck
text: 'syscall/js'
text: "syscall/js"
- linters:
- staticcheck
text: 'SA9003'
text: "SA9003"
- linters:
- typecheck
text: 'github.com/norunners/vert'
text: "by package vert"
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"go.toolsEnvVars": {
"GOOS": "js",
"GOARCH": "wasm"
}
}
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Contributions are welcome to the Go compiler!

### Go

[Go][go] `1.17.x` is needed to work with this repo. On Macs, installing via [Homebrew][homebrew] is recommended: `brew install go`. For Windows & Linux, you can [follow Go’s installation guide][go] if you don’t have your own preferred method of package installation.
[Go][go] `1.19.x` is needed to work with this repo. On Macs, installing via [Homebrew][homebrew] is recommended: `brew install go`. For Windows & Linux, you can [follow Go’s installation guide][go] if you don’t have your own preferred method of package installation.

If you use VS Code as your primary editor, installing the [Go extension][go-vscode] is highly recommended.

Expand Down
29 changes: 12 additions & 17 deletions cmd/astro-wasm/astro-wasm.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
//go:build js && wasm
// +build js,wasm

package main

import (
Expand All @@ -23,8 +20,6 @@ import (
wasm_utils "github.com/withastro/compiler/internal_wasm/utils"
)

var done chan bool

func main() {
js.Global().Set("@astrojs/compiler", js.ValueOf(make(map[string]interface{})))
module := js.Global().Get("@astrojs/compiler")
Expand Down Expand Up @@ -114,7 +109,7 @@ func makeTransformOptions(options js.Value) transform.TransformOptions {
staticExtraction = true
}

var resolvePath interface{} = options.Get("resolvePath")
var resolvePath any = options.Get("resolvePath")
var resolvePathFn func(string) string
if resolvePath.(js.Value).Type() == js.TypeFunction {
resolvePathFn = func(id string) string {
Expand Down Expand Up @@ -216,8 +211,8 @@ func preprocessStyle(i int, style *astro.Node, transformOptions transform.Transf
style.FirstChild.Data = str
}

func Parse() interface{} {
return js.FuncOf(func(this js.Value, args []js.Value) interface{} {
func Parse() any {
return js.FuncOf(func(this js.Value, args []js.Value) any {
source := jsString(args[0])
parseOptions := makeParseOptions(js.Value(args[1]))
transformOptions := makeTransformOptions(js.Value(args[1]))
Expand All @@ -237,12 +232,12 @@ func Parse() interface{} {
return vert.ValueOf(ParseResult{
AST: string(result.Output),
Diagnostics: h.Diagnostics(),
})
}).Value
})
}

func ConvertToTSX() interface{} {
return js.FuncOf(func(this js.Value, args []js.Value) interface{} {
func ConvertToTSX() any {
return js.FuncOf(func(this js.Value, args []js.Value) any {
source := jsString(args[0])
transformOptions := makeTransformOptions(js.Value(args[1]))
transformOptions.Scope = "XXXXXX"
Expand All @@ -269,20 +264,20 @@ func ConvertToTSX() interface{} {
Code: code,
Map: sourcemapString,
Diagnostics: h.Diagnostics(),
})
}).Value
})
}

func Transform() interface{} {
return js.FuncOf(func(this js.Value, args []js.Value) interface{} {
func Transform() any {
return js.FuncOf(func(this js.Value, args []js.Value) any {
source := jsString(args[0])

transformOptions := makeTransformOptions(js.Value(args[1]))
transformOptions.Scope = astro.HashFromSourceAndModuleId(source, transformOptions.ModuleId)
h := handler.NewHandler(source, transformOptions.Filename)

styleError := []string{}
handler := js.FuncOf(func(this js.Value, args []js.Value) interface{} {
handler := js.FuncOf(func(this js.Value, args []js.Value) any {
resolve := args[0]

go func() {
Expand Down Expand Up @@ -426,8 +421,8 @@ func Transform() interface{} {
StyleError: styleError,
})
}
value.Set("diagnostics", vert.ValueOf(h.Diagnostics()))
resolve.Invoke(value)
value.Set("diagnostics", vert.ValueOf(h.Diagnostics()).Value)
resolve.Invoke(value.Value)
}()

return nil
Expand Down
6 changes: 2 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
module github.com/withastro/compiler

go 1.17
go 1.19

require (
github.com/google/go-cmp v0.5.9
github.com/iancoleman/strcase v0.2.0
github.com/lithammer/dedent v1.1.0
github.com/norunners/vert v0.0.0-20211229045251-b4c39e2856da
github.com/norunners/vert v0.0.0-20221203075838-106a353d42dd
github.com/tdewolff/parse/v2 v2.6.4
golang.org/x/net v0.0.0-20221004154528-8021a29435af
golang.org/x/sys v0.0.0-20221010170243-090e33056c14
)

replace github.com/norunners/vert => github.com/natemoo-re/vert v0.0.0-natemoo-re.8
23 changes: 3 additions & 20 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,33 +1,16 @@
github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/iancoleman/strcase v0.2.0 h1:05I4QRnGpI0m37iZQRuskXh+w77mr6Z41lwQzuHLwW0=
github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
github.com/lithammer/dedent v1.1.0 h1:VNzHMVCBNG1j0fh3OrsFRkVUwStdDArbgBWoPAffktY=
github.com/lithammer/dedent v1.1.0/go.mod h1:jrXYCQtgg0nJiN+StA2KgR7w6CiQNv9Fd/Z9BP0jIOc=
github.com/natemoo-re/vert v0.0.0-natemoo-re.8 h1:RCxCOL0e2bvB0wrmF/77X8/uewz/K7iU4TjVqpZm/T4=
github.com/natemoo-re/vert v0.0.0-natemoo-re.8/go.mod h1:67MuD9cDWe6pmhyQrElFlSNMMzL0CMUdFURKxJSvxUM=
github.com/tdewolff/parse/v2 v2.5.22 h1:KXMHTyx4VTL6Zu9a94SULQalDMvtP5FQq10mnSfaoGs=
github.com/tdewolff/parse/v2 v2.5.22/go.mod h1:WzaJpRSbwq++EIQHYIRTpbYKNA3gn9it1Ik++q4zyho=
github.com/tdewolff/parse/v2 v2.5.27 h1:PL3LzzXaOpmdrknnOlIeO2muIBHAwiKp6TxN1RbU5gI=
github.com/tdewolff/parse/v2 v2.5.27/go.mod h1:WzaJpRSbwq++EIQHYIRTpbYKNA3gn9it1Ik++q4zyho=
github.com/norunners/vert v0.0.0-20221203075838-106a353d42dd h1:tHn7K76q9eJ2rXLH/OoxHkdprM3l2A+0kdxOrKYcV7U=
github.com/norunners/vert v0.0.0-20221203075838-106a353d42dd/go.mod h1:8iuQLyTSvuzwy6R6l6w6J+i9c/6xPEVoVdcMz9E8FEw=
github.com/tdewolff/parse/v2 v2.6.4 h1:KCkDvNUMof10e3QExio9OPZJT8SbdKojLBumw8YZycQ=
github.com/tdewolff/parse/v2 v2.6.4/go.mod h1:woz0cgbLwFdtbjJu8PIKxhW05KplTFQkOdX78o+Jgrs=
github.com/tdewolff/test v1.0.6 h1:76mzYJQ83Op284kMT+63iCNCI7NEERsIN8dLM+RiKr4=
github.com/tdewolff/test v1.0.6/go.mod h1:6DAvZliBAAnD7rhVgwaM7DE5/d9NMOAJ09SqYqeK4QE=
github.com/tdewolff/test v1.0.7 h1:8Vs0142DmPFW/bQeHRP3MV19m1gvndjUb1sn8yy74LM=
github.com/tdewolff/test v1.0.7/go.mod h1:6DAvZliBAAnD7rhVgwaM7DE5/d9NMOAJ09SqYqeK4QE=
golang.org/x/net v0.0.0-20210716203947-853a461950ff h1:j2EK/QoxYNBsXI4R7fQkkRUk8y6wnOBI+6hgPdP/6Ds=
golang.org/x/net v0.0.0-20210716203947-853a461950ff/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20221004154528-8021a29435af h1:wv66FM3rLZGPdxpYL+ApnDe2HzHcTFta3z5nsc13wI4=
golang.org/x/net v0.0.0-20221004154528-8021a29435af/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da h1:b3NXsE2LusjYGGjL5bxEVZZORm/YEFFrWFjR8eFrw/c=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20221010170243-090e33056c14 h1:k5II8e6QD8mITdi+okbbmR/cIyEbeXLBhy5Ha4nevyc=
golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=