Golang Basics Part I
October 20, 2019 · View on GitHub
Golang Basics Part I
Please complete the courses, tutorials and tasks listed below:
Theory
- As any young gopher we start by passing "Tour of Go"
- Go through 1-7 chapter at Golangbootcamp. Check your knowledge with exercizes at the end of 3,4,5,7 chapters.
- Read Introduction, Formatting, Commentary, Names, Semicolons, Control structures, Functions and Data chapters from Effective Go article written by go language developers.
- Read following important articles:
Learn golang typed untyped constants
Understand go pointers in less than 800 words or your money back
If a map isn't a reference variable what is it
Interface values are valueless
Practical task
- In your
kottans-backendfolder create folder calleddigits. - In
digitsfolder create file calledmain.go. - Given following string:
const digits =
`
000
0 0
0 0
0 0
0 0
0 0
000
1
1 1
1
1
1
1
11111
222
2 2
2
2
2
2
22222
333
3 3
3
33
3
3 3
333
4
44
4 4
4 4
44444
4
4
55555
5
5
5555
5
5 5
555
666
6 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
999
9 9
9 9
9999
9
9 9
999
`
In main.go create write a program that satisfy following user stories:
- As the user, I can take any unsigned integer (
uint) value to use as argument ingo run main.go <unsigned_integer>call. - Using
uintas input I can get output value as ASCII art in my termanal window. For instance:
go run main.go 1234567890
***********************************************************
1 222 333 4 55555 666 77777 888 999 000
1 1 2 2 3 3 44 5 6 6 7 8 8 9 9 0 0
1 2 3 4 4 5 6 7 8 8 9 9 0 0
1 2 33 4 4 5555 6666 7 888 9999 0 0
1 2 3 44444 5 6 6 7 8 8 9 0 0
1 2 3 3 4 5 5 6 6 7 8 8 9 9 0 0
11111 22222 333 4 555 666 7 888 999 000
***********************************************************
- Note, that asterisk borders are mandatory
- As the user, I can see error message in my terminal if my input is not valid (in case if given more than 1 argument or if 1 argument is not
uintvalue).
- Optional story. Add possibily to set custom pixel symbol for your ASCII art via additional command line argument
symbol. For instance:
go run main.go -symbol @ 1234567890
Will output:
***********************************************************
@ @@@ @@@ @ @@@@@ @@@ @@@@@ @@@ @@@ @@@
@ @ @ @ @ @ @@ @ @ @ @ @ @ @ @ @ @
@ @ @ @ @ @ @ @ @ @ @ @ @ @
@ @ @@ @ @ @@@@ @@@@ @ @@@ @@@@ @ @
@ @ @ @@@@@ @ @ @ @ @ @ @ @ @
@ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @
@@@@@ @@@@@ @@@ @ @@@ @@@ @ @@@ @@@ @@@
***********************************************************
- Useful links
- In your
kottans-backendrepoREADME.md:- add header
## Go basics 1 - embed the link to your
main.gosource code file.
- add header
Code Submission
Save your program in a file. Follow instructions in this repo to submit your code.
- You did lot already! If you honestly finished all the previous steps then go ahead
and share it with others –
post a message in course channel:
Go Basics 1 — #doneand add the link to your repo. This step is important, as it helps mentors to track your progress!
Extra materials
Done?
➡️ Go forward to Memory Management
⤴️ Back to Contents