Full beginner question about scan


it is the fmt package scan function definition:

func Scan(a …interface{}) (n int, err error)

how can I determine from the above function definition that
i have to use a or &a

if I only see the function definition (without documentetion)

using :

var name string

fmt.Scan(&name) or fmt.Scan(name)

thank you attila

Hi @AttilaK . The answer is that in order to obtain the read value (inside the Scan function) outside, you have to pass a pointer :slight_smile: . Passing directly an identifier and not its pointer it’s a stdin value discard.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.