chameth

Untitled

Jul 28th, 2021
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.33 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4.     "io"
  5.     "log"
  6.     "os"
  7. )
  8.  
  9. func main() {
  10.     if len(os.Args) > 1 && os.Args[1] != "-" {
  11.         output(os.ReadFile(os.Args[1]))
  12.     } else {
  13.         output(io.ReadAll(os.Stdin))
  14.     }
  15. }
  16.  
  17. func output(b []byte, err error) {
  18.     if err != nil {
  19.         log.Fatalf("unable to read file %s: %v", os.Args[0], err)
  20.     }
  21.     println(string(b))
  22. }
  23.  
Add Comment
Please, Sign In to add comment