2014-04-14 20:55



I'm using fmt.Fprintf(file, "<string>"), but in a function. I create the new file using xmlFile := in the main function and then pass that variable to the call of a function that writes to the file, but I am getting an error for the file parametre that it doesn't have a type. What type should I give it?

It is not a string, it is a file.

Of what type is a file?

Here is what the definition of the function looks like:

func processTopic(id string, properties map[string][]string, file){
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答


  • duanning9110 duanning9110 7年前

    From the documentation:

    func Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error)

    Fprintf accepts an io.Writer. io.Writer is an interface which means that you an pass any type that implements it. This includes *os.File (system file) and *bytes.Buffer (memory).

    点赞 评论 复制链接分享