Created
July 15, 2018 11:53
-
-
Save rakaadinugroho/c44c82d540eb7e5780b40c18c4b9844e to your computer and use it in GitHub Desktop.
Tutorial GoLang Bahasa Indonesia - Part 2 (Tipe Data, Struct, Interface, Logika)
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
1. Starting Write Code | |
2. Standarisasi Run & Compile | |
3. Sample Import Package | |
4. Create function | |
// Sample Function | |
func add(x int, y int) int { // x, y int | |
return x + y | |
} | |
// Multiple return | |
func swap(x, y string) (string, string) { | |
return y, x | |
} | |
a, b := swap("hello", "world") | |
5. Penulisan Variable | |
var variableName typeData | |
(Case sensitive menunjukan sebuah lingkup variable (public/private)) | |
variable dengan inisialisasi | |
var i, j int = 1, 2 | |
Penulisan Const | |
const Pi = 3.14 | |
6. Flow Control | |
#For | |
for i := 0; i < 10; i++ { | |
sum += i | |
} | |
#IF | |
if x < 0 { | |
return sqrt(-x) + "i" | |
} | |
# Short IF Statement | |
if v := what; v < other { | |
// V Statement | |
} | |
#Switch | |
switch what:=asignment { | |
case x: | |
} | |
#Defer | |
defer what? | |
7. Tipe Lain | |
# Pointer | |
a:= what? | |
b := &a //addressing | |
*b // show pointer | |
#Struct | |
type YourStruct struct { | |
field dataType | |
} | |
Belum banyak ? kedepannya kursus akan menggunakan type" lain, mulai dari array, map, slice, dll. | |
Terimakasih jangan lupa Vidio Tutorial Terbaru ada di: | |
https://www.youtube.com/channel/UCbffo0dSFr91k7W7Sa8YQVg | |
Kembangkan karir kalian di dunia IT Sekarang! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment