Create a gist now

Instantly share code, notes, and snippets.

@cipepser /q11.go
Last active Feb 4, 2017

What would you like to do?
package main
import (
"fmt"
"os"
"bufio"
"log"
)
const (
NULL rune = 0
)
func main() {
if len(os.Args) != 2 {
log.Fatal("Please input filename as a first standard input.")
} else {
fp, err := os.Open(os.Args[1])
if err != nil {
log.Fatal(err)
}
defer fp.Close()
reader := bufio.NewReaderSize(fp, 4096)
for {
p, _, _ := reader.ReadRune()
if p == rune('\t') {
p = rune(' ')
}
if p == NULL {
break
}
fmt.Printf(string(p))
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment