zenrpc icon indicating copy to clipboard operation
zenrpc copied to clipboard

Default value for string arguments with space

Open dizzyfool opened this issue 6 years ago • 1 comments

Setting default value for string parameters with space(s) causes generator error.

Example code:

// Echo returns input string.
//zenrpc:to="John Doe" name goes here 
func (s *Say) Hello(to string) string {
	return fmt.Sprintf("Hey, %v!", to)
}

What I got:

> go generate src/rpc/rpc.go 
Generator version: 1.0.1
Entrypoint: rpc.go
Error: 85:23: string literal not terminated

dizzyfool avatar Apr 07 '18 20:04 dizzyfool

As a work-around, you can use a constant like this:

const defaultHelloTo="John Doe"

// Echo returns input string.
//zenrpc:to=defaultHelloTo name goes here 
func (s *Say) Hello(to string) string {
	return fmt.Sprintf("Hey, %v!", to)
}

smyrman avatar Sep 11 '19 10:09 smyrman