Basis
One, hello
1 package Main 2 3 Import (4 "FMT" 5 "OS" 6 "strings" 7) 8 9 Func Main () {ten Who: = "W Orld "one-to-one" if Len (OS. Args) > 1 { who = strings. Join (OS. Args[1:], "") 13} FMT. Println ("Hello", WHO) 15}
It seems that there is nothing to explain, the direct run on the line.
Two, bigdigits
1Package Main 2 3Import (4 "FMT" 5 "Log" 6 "OS" 7 "Path/filepath" 8 ) 9 TenFunc Main () { One ifLen (OS. Args) = =1 { AFmt. Println ("Usage:%s <whole-number>\n", filepath. Base (OS. args[0])) -Os. Exit (1) - } theStringofdigits: = os. args[1] - forRow: = Range bigdigits[0] { -Line: ="" - forColumn: =Range Stringofdigits { +Digit: = Stringofdigits[column]-'0' - if 0<= Digit && Digit <=9 { +Line + = Bigdigits[digit][row] +" " A}Else { atLog. Fatal ("invalid who number") - } - } -FMT. Println (line) - } - } in - varBigdigits = []string{ to{" the", + "0 0", - "0 0", the "0 0", * "0 0", $ "0 0", Panax Notoginseng " the"}, -{"1"," One","1","1","1","1","111"}, the{"222","2 2","2","2","2","2","22222"}, +{"333","3 3","3"," -","3","3 3","333"}, A{"4"," -","4 4","4 4","444444","4", the "4"}, +{"55555","5","5","555","5","5 5","555"}, -{"666","6","6","6666","6 6","6 6","666"}, ${"77777","7","7","7","7","7","7"}, ${"888","8 8","8 8","888","8 8","8 8","888"}, -{"9999","9 9","9 9","9999","9","9","9"}, - } ~
This piece of code: There seems to be nothing to say. Well, use range to get the offset of the relative ' 0 ' of each parameter number, and then stitch together the string representation of the corresponding line of each number. Sort of like a pixel puzzle.
"Go Language Programming" Learning (ii)