diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..13566b8
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..2a5fc9f
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/tutorial-go.iml b/.idea/tutorial-go.iml
new file mode 100644
index 0000000..5e764c4
--- /dev/null
+++ b/.idea/tutorial-go.iml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/golang-basic/09-structs-interfaces/first-struct-area.go b/golang-basic/09-structs-interfaces/first-struct-area.go
index 8ce17f7..44f09c3 100644
--- a/golang-basic/09-structs-interfaces/first-struct-area.go
+++ b/golang-basic/09-structs-interfaces/first-struct-area.go
@@ -5,15 +5,15 @@ import (
"math"
)
-type Circle struct {
+type Circles struct {
x, y, r float64
}
-func circleArea(c *Circle) float64 {
+func circleArea(c *Circles) float64 {
return math.Pi * c.r * c.r
}
func main() {
- c := Circle{0, 0, 5}
+ c := Circles{0, 0, 5}
fmt.Println(circleArea(&c))
}
diff --git a/golang-basic/09-structs-interfaces/manual-function.go b/golang-basic/09-structs-interfaces/manual-function.go
index 539740e..b6301cc 100644
--- a/golang-basic/09-structs-interfaces/manual-function.go
+++ b/golang-basic/09-structs-interfaces/manual-function.go
@@ -17,7 +17,7 @@ func rectangleArea(x1, y1, x2, y2 float64) float64 {
return l * w
}
-func circleArea(x, y, r float64) float64 {
+func circleAreas(x, y, r float64) float64 {
return math.Pi * r * r
}
@@ -26,5 +26,5 @@ func main() {
var rx2, ry2 float64 = 10, 10
var cx, cy, cr float64 = 0, 0, 5
fmt.Println(rectangleArea(rx1, ry1, rx2, ry2))
- fmt.Println(circleArea(cx, cy, cr))
+ fmt.Println(circleAreas(cx, cy, cr))
}
diff --git a/golang-basic/latihan/01-noverry-ambo.go b/golang-basic/latihan/01-noverry-ambo.go
new file mode 100644
index 0000000..dbfa79b
--- /dev/null
+++ b/golang-basic/latihan/01-noverry-ambo.go
@@ -0,0 +1,42 @@
+/*
+Soal 1
+Buat program `palindrome` menggunakan golang
+
+$ go main.go
+$ madam
+
+output
+true
+
+*/
+
+package main
+
+import "fmt"
+
+func isPalindrome(input string) bool {
+
+ for i := 0; i < len(input)/2; i++ {
+ if input[i] != input[len(input)-i-1] {
+ return false
+ }
+ }
+ return true
+}
+
+func main() {
+
+ var str string
+
+ fmt.Print("Cek Palindrome : ")
+ fmt.Scan(&str)
+
+ result := isPalindrome(str)
+
+ if result == true {
+ fmt.Println("true")
+ } else {
+ fmt.Println("false")
+ }
+
+}
diff --git a/golang-basic/latihan/02-noverry-ambo.go b/golang-basic/latihan/02-noverry-ambo.go
new file mode 100644
index 0000000..b070f1e
--- /dev/null
+++ b/golang-basic/latihan/02-noverry-ambo.go
@@ -0,0 +1,38 @@
+/* Soal 2
+ Buat program untuk menentukan Huruf yang diinput Vokal atau Konsonan
+ >>> input
+ $ go main .go
+ h
+ >>> output
+ Konsonan
+*/
+
+package main
+
+import "fmt"
+
+func isVocal(vocal string) string {
+
+ if vocal == "a" || vocal == "e" || vocal == "i" || vocal == "o" || vocal == "u" {
+ vocal = "Vokal"
+ } else {
+ vocal = "Konsonan"
+ }
+
+ return vocal
+}
+
+func main() {
+ var vocal string
+ fmt.Print("Masukkan huruf : ")
+ fmt.Scan(&vocal)
+
+ result := isVocal(vocal)
+
+ if result == "Vokal" {
+ fmt.Println("Vokal")
+ } else {
+ fmt.Println("Konsonan")
+ }
+
+}
diff --git a/gomodule-unit-test/latihan/03-noverry-ambo.go b/gomodule-unit-test/latihan/03-noverry-ambo.go
new file mode 100644
index 0000000..e6cfcb5
--- /dev/null
+++ b/gomodule-unit-test/latihan/03-noverry-ambo.go
@@ -0,0 +1,11 @@
+package main
+
+func isVocal(vocal string) string {
+
+ if vocal == "a" || vocal == "e" || vocal == "i" || vocal == "o" || vocal == "u" {
+ vocal = "Vokal"
+ } else {
+ vocal = "Konsonan"
+ }
+ return vocal
+}
diff --git a/gomodule-unit-test/latihan/03-noverry-ambo_test.go b/gomodule-unit-test/latihan/03-noverry-ambo_test.go
new file mode 100644
index 0000000..631d6d0
--- /dev/null
+++ b/gomodule-unit-test/latihan/03-noverry-ambo_test.go
@@ -0,0 +1,26 @@
+package main
+
+import "testing"
+
+func Test_isVocal(t *testing.T) {
+ type args struct {
+ vocal string
+ }
+ tests := []struct {
+ name string
+ args args
+ want string
+ }{
+ {
+ name: "konsonan or vocal",
+ args: args{
+ vocal: "madam",
+ },
+ want: "Konsonan",
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ })
+ }
+}
diff --git a/gomodule-unit-test/latihan/04-noverry-ambo.go b/gomodule-unit-test/latihan/04-noverry-ambo.go
new file mode 100644
index 0000000..7f84fe3
--- /dev/null
+++ b/gomodule-unit-test/latihan/04-noverry-ambo.go
@@ -0,0 +1,11 @@
+package main
+
+func isPalindrome(input string) bool {
+
+ for i := 0; i < len(input)/2; i++ {
+ if input[i] != input[len(input)-i-1] {
+ return false
+ }
+ }
+ return true
+}
diff --git a/gomodule-unit-test/latihan/04-noverry-ambo_test.go b/gomodule-unit-test/latihan/04-noverry-ambo_test.go
new file mode 100644
index 0000000..ce65194
--- /dev/null
+++ b/gomodule-unit-test/latihan/04-noverry-ambo_test.go
@@ -0,0 +1,33 @@
+package main
+
+import "testing"
+
+func Test_isPalindrome(t *testing.T) {
+ type args struct {
+ input string
+ }
+ tests := []struct {
+ name string
+ args args
+ want bool
+ }{
+ {
+ name: "konsonan or vocal",
+ args: args{
+ input: "madam",
+ },
+ want: true,
+ },
+ {
+ name: "konsonan or vocal",
+ args: args{
+ input: "rusak",
+ },
+ want: false,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ })
+ }
+}