Browse Source

echo2, echo3

龚成明 2 năm trước cách đây
mục cha
commit
dd41229974
2 tập tin đã thay đổi với 26 bổ sung0 xóa
  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:], " "))
+}