Created
February 4, 2018 05:44
-
-
Save dviramontes/45977d7b59bd5780372c34eb2daf3ab4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// print name of calling program, | |
// list args passed each on a new line, | |
// print time elapsed | |
package main | |
import ( | |
"fmt" | |
"os" | |
"strings" | |
"time" | |
) | |
func main() { | |
start := time.Now() | |
fmt.Println("binary's name => ", os.Args[0]) | |
// op1 | |
// --- | |
// s, sep := "", " " | |
// for i, arg := range os.Args[1:] { | |
// s = strconv.Itoa(i) + sep + arg | |
// fmt.Println(s) | |
// } | |
// op2 | |
// --- | |
// (fastest but cant get reference to index ?) | |
fmt.Println(strings.Join(os.Args[1:], "\n")) | |
end := time.Now() | |
elapsed := end.Sub(start) | |
fmt.Println("time elapsed: " + elapsed.String()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment