init project
authorwatkinsr <ryanwatkins54@gmail.com>
Thu, 21 May 2020 01:17:11 +0000 (02:17 +0100)
committerwatkinsr <ryanwatkins54@gmail.com>
Thu, 21 May 2020 01:17:11 +0000 (02:17 +0100)
echo1.go [new file with mode: 0644]
echo2.go [new file with mode: 0644]
echo3.go [new file with mode: 0644]
echo4.go [new file with mode: 0644]
helloworld.go [new file with mode: 0644]

diff --git a/echo1.go b/echo1.go
new file mode 100644 (file)
index 0000000..3f066f1
--- /dev/null
+++ b/echo1.go
@@ -0,0 +1,15 @@
+package main
+
+import (
+    "fmt"
+    "os"
+)
+
+func main() {
+    var s, sep string
+    for i := 1; i < len(os.Args); i++ {
+               s += sep + os.Args[i]
+               sep = " "
+    }
+       fmt.Println(s);
+}
diff --git a/echo2.go b/echo2.go
new file mode 100644 (file)
index 0000000..03d22fe
--- /dev/null
+++ b/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);
+}
diff --git a/echo3.go b/echo3.go
new file mode 100644 (file)
index 0000000..e88e1f2
--- /dev/null
+++ b/echo3.go
@@ -0,0 +1,14 @@
+package main
+
+import (
+       "fmt"
+       "os"
+       "strings"
+       "time"
+)
+
+func main() {
+    start := time.Now()
+       fmt.Println(strings.Join(os.Args[1:], " "))
+       fmt.Printf("%dns elapsed\n", time.Since(start).Nanoseconds());
+}
diff --git a/echo4.go b/echo4.go
new file mode 100644 (file)
index 0000000..03ce5b2
--- /dev/null
+++ b/echo4.go
@@ -0,0 +1,15 @@
+package main
+
+import (
+       "fmt"
+       "os"
+       "time"
+)
+
+func main() {
+       start := time.Now()
+       for i := 0; i < len(os.Args); i++ {
+               fmt.Printf("%v %v\n", i, os.Args[i])
+       }
+       fmt.Printf("%dns elapsed\n", time.Since(start).Nanoseconds())
+}
diff --git a/helloworld.go b/helloworld.go
new file mode 100644 (file)
index 0000000..f7b60bd
--- /dev/null
@@ -0,0 +1,7 @@
+package main
+
+import "fmt"
+
+func main() {
+       fmt.Println("Hello, world!")
+}