2016-12-30 06:25 阅读 63


Here is my code: package main

import "log"
import "fmt"

func main() {
    var a string = "initail"
    var b, c int = 1, 2
    fmt.Println(b, c)

The output is:

1 2
2016/12/30 14:22:58 initail

So i don't understand why the output's order? why log.Println is slower than fmt.Println?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

1条回答 默认 最新

  • 已采纳
    dqu94359 dqu94359 2016-12-30 06:42

    Only difference between those in terms of its printing behaviour is

    • log.Println writes to Stderr
    • fmt.Println writes to Stdout

    Both are not buffered. So the fact that StdOut came before StdError is specific to your terminal or environment.

    Here is a play link

    点赞 评论 复制链接分享