douliaotong4944
douliaotong4944
2014-04-14 20:55

在Go中,当我使用fmt.Printf时文件是什么类型?

已采纳

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){
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

  • 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).

    点赞 评论 复制链接分享

相关推荐