apply minor cleanups suggested by tools

GARBLE_PARENT_WORK hasn't been used for a while.
A couple of other minor simplifications.
This commit is contained in:
Daniel Martí
2025-01-16 23:05:43 +00:00
committed by Paul Scheduikat
parent 83a06019be
commit 97ae350b0e
4 changed files with 6 additions and 11 deletions

View File

@@ -117,7 +117,7 @@ func BenchmarkBuild(b *testing.B) {
// The cached rebuild will reuse all dependencies,
// but rebuild the main package itself.
if cached {
writeSourceFile("rebuild.go", []byte(fmt.Sprintf("package main\nvar v%d int", i)))
writeSourceFile("rebuild.go", fmt.Appendf(nil, "package main\nvar v%d int", i))
}
cmd := exec.Command(os.Args[0], args...)

View File

@@ -11,7 +11,7 @@ import (
// setUnexportedField is used to modify unexported fields of ssa api structures.
// TODO: find an alternative way to access private fields or raise a feature request upstream
func setUnexportedField(objRaw interface{}, name string, valRaw interface{}) {
func setUnexportedField(objRaw any, name string, valRaw any) {
obj := reflect.ValueOf(objRaw)
for obj.Kind() == reflect.Pointer || obj.Kind() == reflect.Interface {
obj = obj.Elem()

11
main.go
View File

@@ -151,7 +151,6 @@ var (
fset = token.NewFileSet()
sharedTempDir = os.Getenv("GARBLE_SHARED")
parentWorkDir = os.Getenv("GARBLE_PARENT_WORK")
)
const actionGraphFileName = "action-graph.json"
@@ -601,15 +600,11 @@ This command wraps "go %s". Below is its help:
return nil, err
}
os.Setenv("GARBLE_SHARED", sharedTempDir)
wd, err := os.Getwd()
if err != nil {
return nil, err
}
os.Setenv("GARBLE_PARENT_WORK", wd)
if flagDebugDir != "" {
if !filepath.IsAbs(flagDebugDir) {
flagDebugDir = filepath.Join(wd, flagDebugDir)
flagDebugDir, err = filepath.Abs(flagDebugDir)
if err != nil {
return nil, err
}
if err := os.RemoveAll(flagDebugDir); err != nil {

View File

@@ -39,7 +39,7 @@ func generateRunSrc() string {
sb.WriteString(`
var alwaysFalseFlag = false
func noop(i interface{}) {
func noop(i any) {
if alwaysFalseFlag {
println(i)
}