Skip to content

Instantly share code, notes, and snippets.

View xvbnm48's full-sized avatar
🇯🇵
Golang addict and weebo

M Fariz Wisnu prananda xvbnm48

🇯🇵
Golang addict and weebo
View GitHub Profile
@xvbnm48
xvbnm48 / hello.go
Last active March 3, 2022 12:58
simple program golang hello world
package main
import "fmt"
func main(){
fmt.Println("Hello World")
}
@xvbnm48
xvbnm48 / switch.go
Created March 4, 2022 14:02
switch golang
package main
import "fmt"
func main(){
nilai := 3
switch nilai {
case 1:
fmt.Println("nilai 1")
@xvbnm48
xvbnm48 / for.go
Created March 4, 2022 14:27
for loop golang
package main
import "fmt"
func main(){
for i := 1; i <= 10; i++ {
fmt.Println("sakura endo cantik", i)
}
}
@xvbnm48
xvbnm48 / array.go
Created March 4, 2022 15:13
array golang
package main
import "fmt"
func main(){
var nama_idol [4]string
nama_idol[0] = "sakura miyawaki"
nama_idol[1] = "aruno nakanishi"
nama_idol[2] = "sakura endo"
nama_idol[3] = "Itou Miku"
@xvbnm48
xvbnm48 / array_simple.go
Created March 4, 2022 15:23
simple array
package main
import "fmt"
func main(){
var idol_grub = [4]string{"JKT48", "HKT48", "NOGIZAKA46", "AKB48"}
fmt.Println(idol_grub)
}
@xvbnm48
xvbnm48 / slice.go
Created March 4, 2022 15:28
slice golang
package main
import "fmt"
func main() {
var vtuber = []string{"korone", "pekora", "moona"}
// tanpa memberikan berapa jumlah array
var newVtuber = vtuber[1:3]
fmt.Println(newVtuber)
}
@xvbnm48
xvbnm48 / map.go
Created March 5, 2022 15:17
map in go
package main
import "fmt"
func main(){
var idol map[string]string
idol = make(map[string]string)
idol["name"] = "sakura"
idol["age"] = "20"
@xvbnm48
xvbnm48 / slice_map.go
Created March 5, 2022 15:41
slice map
package main
import "fmt"
func main() {
// slice of map
students := []map[string]string{
{"name": "sakura", "age": "20", "address": "jepang"},
{"name": "aruno", "age": "20", "address": "jepang"},
{"name": "sakura endo", "age": "20", "address": "jepang"},
@xvbnm48
xvbnm48 / function.go
Created March 5, 2022 15:48
function in golang
package main
import "fmt"
func main(){
printMyResult("sakura")
}
func printMyResult(sentence string) {
@xvbnm48
xvbnm48 / function_return_value.go
Created March 5, 2022 15:54
function return vbalue
package main
import "fmt"
func main(){
JumlahLuas, jumlahKeliling := hitungReturnValue(30, 20)
fmt.Println("luas", JumlahLuas, "keliling", jumlahKeliling)
}
func hitungReturnValue(panjang, lebar int) (luas int, keliling int) {