printing
# Node.js
console.log("print to stdout");
console.log("format %s %d", "example", 1);
console.error("print to stderr");
1
2
3
2
3
Output
print to stdout
format example 1
print to stderr
1
2
3
2
3
# Go
package main
import (
"fmt"
"os"
)
func main() {
fmt.Println("print to stdout")
fmt.Printf("format %s %v\n", "example", 1)
fmt.Fprintf(os.Stderr, "print to stderr")
}
1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12
Output
print to stdout
format example 1
print to stderr
1
2
3
2
3
编辑 (opens new window)
上次更新: 2022/09/30, 11:34:22