龚成明 %!s(int64=2) %!d(string=hai) anos
pai
achega
dd41229974
Modificáronse 2 ficheiros con 26 adicións e 0 borrados
  1. 15 0
      chapter01/echo2.go
  2. 11 0
      chapter01/echo3.go

+ 15 - 0
chapter01/echo2.go

@@ -0,0 +1,15 @@
+package main
+
+import (
+	"fmt"
+	"os"
+)
+
+func main() {
+	s, sep := "", ""
+	for _, arg := range os.Args[1:] {
+		s += sep + arg
+		sep = " "
+	}
+	fmt.Println(s)
+}

+ 11 - 0
chapter01/echo3.go

@@ -0,0 +1,11 @@
+package main
+
+import (
+	"fmt"
+	"os"
+	"strings"
+)
+
+func main() {
+	fmt.Println(strings.Join(os.Args[1:], " "))
+}