Skip to content

garble can't work with github.com/AlecAivazis/survey/v2 #791

@kkqy

Description

@kkqy

What version of Garble and Go are you using?

$ garble version
mvdan.cc/garble v0.10.1

Build settings:
      -buildmode exe
       -compiler gc
     CGO_ENABLED 1
          GOARCH amd64
            GOOS windows
         GOAMD64 v1

$ go version
go version go1.20.7 windows/amd64

What environment are you running Garble on?

go env Output
$ go env
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\User\AppData\Local\go-build
set GOENV=C:\Users\User\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\User\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\User\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Program Files\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.20.7
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=clang
set CXX=clang++
set CGO_ENABLED=1
set GOMOD=D:\projects\test\go.mod
set GOWORK=
set CGO_CFLAGS=-O2 -g
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=C:\Users\User\AppData\Local\Temp\go-build2700964290=/tmp/go-build -gno-record-gcc-switches

What did you do?

  1. code here:
package main

import (
	"fmt"

	"github.com/AlecAivazis/survey/v2"
)

func broken() {
	var input string
	err := survey.AskOne(&survey.Select{
		Message: "please choose:",
		Options: []string{"Option1", "Option2"},
	}, &input)

	if err != nil {
		// crash here
		panic(err)
	}
	fmt.Println(input)
}
func main() {
	broken()

}
  1. garble it:
    garble build -ldflags="-s -w" .

What did you expect to see?

It should print what I choose.

What did you see instead?

panic:

panic: template: prompt:4:19: executing "option" at <.CurrentOpt.Value>: can't evaluate field Value in type hXCS2oWxzi9.DYdqhhUhlOQ

goroutine 1 [running]:
main.uHhC2SXRwzv()
        Oeubp4hOAGzv.go:1 +0x1b1
main.main()
        FQt7OAGNPv.go:1 +0x17

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions