go-snark-study icon indicating copy to clipboard operation
go-snark-study copied to clipboard

go build error

Open triplewz opened this issue 6 years ago • 3 comments

Hello, when i tried to build main.go, it showed that

# github.com/arnaucube/go-snark/cli
./main.go:57:3: cannot use []cli.Command literal (type []cli.Command) as type []*cli.Command in field value
./main.go:85:17: cannot use cli.StringFlag literal (type cli.StringFlag) as type cli.Flag in array or slice literal:
	cli.StringFlag does not implement cli.Flag (Apply method has pointer receiver)
./main.go:87:15: cannot use commands (type []cli.Command) as type []*cli.Command in assignment

What's the reason?

triplewz avatar Nov 21 '19 02:11 triplewz

I use the following code, and it works fine.

var commands = []*cli.Command{         // pointer
	{
		Name:    "compile",
		Aliases: []string{},
		Usage:   "compile a circuit",
		Action:  CompileCircuit,
	},
	{
		Name:    "trustedsetup",
		Aliases: []string{},
		Usage:   "generate trusted setup for a circuit",
		Action:  TrustedSetup,
	},
	{
		Name:    "genproofs",
		Aliases: []string{},
		Usage:   "generate the snark proofs",
		Action:  GenerateProofs,
	},
	{
		Name:    "verify",
		Aliases: []string{},
		Usage:   "verify the snark proofs",
		Action:  VerifyProofs,
	},
	{
		Name:    "groth16",
		Aliases: []string{},
		Usage:   "use groth16 protocol",
		Subcommands: []*cli.Command{                        //pointer
			{
				Name:    "trustedsetup",
				Aliases: []string{},
				Usage:   "generate trusted setup for a circuit",
				Action:  Groth16TrustedSetup,
			},
			{
				Name:    "genproofs",
				Aliases: []string{},
				Usage:   "generate the snark proofs",
				Action:  Groth16GenerateProofs,
			},
			{
				Name:    "verify",
				Aliases: []string{},
				Usage:   "verify the snark proofs",
				Action:  Groth16VerifyProofs,
			},
		},
	},
}

func main() {
	app := cli.NewApp()
	app.Name = "go-snarks-cli"
	app.Version = "0.0.3-alpha"
	app.Flags = []cli.Flag{
		&cli.StringFlag{Name: "config"},     //
	}
	app.Commands = commands

	err := app.Run(os.Args)
	if err != nil {
		log.Fatal(err)
	}
}

triplewz avatar Nov 21 '19 03:11 triplewz

Which version are you using? I've tried just now with the current master version of this repo, and worked fine Which version of the urfave/cli are you using ( https://github.com/arnaucube/go-snark/blob/master/go.mod#L7 )?

arnaucube avatar Nov 21 '19 07:11 arnaucube

Ok, I used version 2 of the urfave/cli, maybe this is the reason.

triplewz avatar Nov 21 '19 08:11 triplewz