douliaotong4944 2014-04-14 20:55
浏览 11
已采纳

在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 2014-04-14 21:19
    关注

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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试