Last active
February 4, 2017 00:45
-
-
Save cipepser/848871be78390be2901e02908051ccc7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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