Skip to content

Instantly share code, notes, and snippets.

@cipepser
Last active February 4, 2017 00:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cipepser/848871be78390be2901e02908051ccc7 to your computer and use it in GitHub Desktop.
Save cipepser/848871be78390be2901e02908051ccc7 to your computer and use it in GitHub Desktop.
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