make garble work on Go tip again

Just two minor tweaks were necessary to get "go test" to pass on:

	go version devel go1.17-a25c584629 Tue Apr 6 04:48:09 2021 +0000 linux/amd64

Re-enable the CI for it, too. The config needed changing since the
set-env and add-path commands now use special files instead, due to some
security issues uncovered last winter.

It's possible that CI on master could suddenly break, if Go master
changes in some substantial way that requires more tweaks. If that turns
out to be an issue pretty often, we could always pin a specific git repo
commit and update it every few weeks.
pull/307/head
Daniel Martí 4 years ago committed by Andrew LeFevre
parent 5d49955998
commit d38dfd4e90

@ -25,24 +25,23 @@ jobs:
go version go version
go test ./... go test ./...
# TODO: re-enable once we get Go master/tip working again test-gotip:
#test-gotip: runs-on: ubuntu-latest
# runs-on: ubuntu-latest continue-on-error: true # master breaks sometimes
# continue-on-error: true # master breaks sometimes steps:
# steps: - name: Install Go
# - name: Install Go run: |
# run: | git clone --depth=1 https://go.googlesource.com/go $HOME/gotip
# git clone --depth=1 https://go.googlesource.com/go $HOME/gotip cd $HOME/gotip/src
# cd $HOME/gotip/src ./make.bash
# ./make.bash echo "GOROOT=$HOME/gotip" >>$GITHUB_ENV
# echo "::set-env name=GOROOT::$HOME/gotip" echo "$HOME/gotip/bin" >>$GITHUB_PATH
# echo "::add-path::$HOME/gotip/bin" - name: Checkout code
# - name: Checkout code uses: actions/checkout@v2
# uses: actions/checkout@v2 - name: Test
# - name: Test run: |
# run: | go version
# go version go test ./...
# go test ./...
code-checks: code-checks:
runs-on: ubuntu-latest runs-on: ubuntu-latest

@ -817,6 +817,10 @@ var runtimeRelated = map[string]bool{
"unsafe": true, "unsafe": true,
"vendor/golang.org/x/net/dns/dnsmessage": true, "vendor/golang.org/x/net/dns/dnsmessage": true,
"vendor/golang.org/x/net/route": true, "vendor/golang.org/x/net/route": true,
// Manual additions for Go 1.17 as of April 2021.
"internal/abi": true,
"internal/itoa": true,
} }
// isPrivate checks if a package import path should be considered private, // isPrivate checks if a package import path should be considered private,

@ -64,10 +64,6 @@ func printFile(file1 *ast.File) ([]byte, error) {
toAdd = append(toAdd, commentToAdd{offset, text}) toAdd = append(toAdd, commentToAdd{offset, text})
} }
// Make sure the entire file gets a zero filename by default,
// in case we miss any positions below.
addComment(0, "/*line :1*/")
// Remove any comments by making them whitespace. // Remove any comments by making them whitespace.
// Keep directives, as they affect the build. // Keep directives, as they affect the build.
// This is superior to removing the comments before printing, // This is superior to removing the comments before printing,
@ -123,6 +119,13 @@ func printFile(file1 *ast.File) ([]byte, error) {
copied := 0 copied := 0
var buf2 bytes.Buffer var buf2 bytes.Buffer
// Make sure the entire file gets a zero filename by default,
// in case we miss any positions below.
// We use a //-style comment, because there might be build tags.
// addComment is for /*-style comments, so add it to buf2 directly.
buf2.WriteString("//line :1\n")
for _, comment := range toAdd { for _, comment := range toAdd {
buf2.Write(src[copied:comment.offset]) buf2.Write(src[copied:comment.offset])
copied = comment.offset copied = comment.offset

Loading…
Cancel
Save