package main

import (
	"fmt"
	"io"
	"os"
)

var ARGV []string

func main() {
	ARGV = os.Args[1:]

	if len(ARGV) == 0 {
		// Read stdin only
		io.Copy(os.Stdout, os.Stdin)

	} else {
		// Read ARGV only
		for _, filename := range ARGV {
			if filename == "--" {
				continue
			}

			// - means read stdin as a special case
			if filename == "-" {
				filename = "/dev/stdin"
			}

			// Otherwise we're after a file itself
			f, err := os.Open(filename)
			if err != nil {
				fmt.Fprintf(os.Stderr, "gocat: %s: No such file or directory\n", filename)
				continue
			}

			// Copy our output across!
			io.Copy(os.Stdout, f)
		}

	}
}

package main

import (
	"fmt"
	"io"
	"os"
)

var ARGV []string

func main() {
	ARGV = os.Args[1:]

	if len(ARGV) >= 1 {
		for _, filename := range ARGV {
			if filename == "--" {
				continue
			}

			// - means read stdin as a special case
			if filename == "-" {
				filename = "/dev/stdin"
			}

			// Otherwise we're after a file itself
			f, err := os.Open(filename)
			if err != nil {
				fmt.Fprintf(os.Stderr, "gocat: %s: No such file or directory\n", filename)
				continue
			}

			// Copy our output across!
			io.Copy(os.Stdout, f)
		}
	}
}

--- 
+++ 
@@ -11,7 +11,12 @@
 func main() {
 	ARGV = os.Args[1:]
 
-	if len(ARGV) >= 1 {
+	if len(ARGV) == 0 {
+		// Read stdin only
+		io.Copy(os.Stdout, os.Stdin)
+
+	} else {
+		// Read ARGV only
 		for _, filename := range ARGV {
 			if filename == "--" {
 				continue
@@ -32,5 +37,6 @@
 			// Copy our output across!
 			io.Copy(os.Stdout, f)
 		}
+
 	}
 }
Read stdin if no arguments given
