I need to learn User and write to a text file, how can I convert to type string ?
Code:
package main import "os" import "os/user" func main(){ f, err := os.OpenFile("test.txt", os.O_APPEND|os.O_WRONLY, 0600) if err != nil { panic(err) } defer f.Close() cur, err := user.Current() if err != nil { } else { if _, err = f.WriteString(cur); err != nil { panic(err) } } } Mistake:
# command-line-arguments .\os.go:18:31: cannot use cur (type *user.User) as type string in argument to f.WriteString