Re: [go-nuts] Help, using fmt.Sprint

2017-09-01 Thread Sam Whited
On Fri, Sep 1, 2017, at 10:00, Tong Sun wrote:
> For normal Go way, should I name the string function `*String*()` or `
> *ToString*()`? 

If you want your type to satisfy the `fmt.Stringer' interface
(https://godoc.org/fmt#Stringer) the method should be named `String'.

—Sam

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Help, using fmt.Sprint

2017-09-01 Thread Shawn Milochik
fmt.Sprint returns a string. You're not assigning it to a variable, so it's
"lost."

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Help, using fmt.Sprint

2017-09-01 Thread Tong Sun
Hi, 

What's wrong with my usage of `fmt.Sprint` in this code:

https://play.golang.org/p/ypzfUF_xXA

BTW, 

For normal Go way, should I name the string function `*String*()` or `
*ToString*()`? 

Thanks


-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.