diff options
| author | Mhd Sulhan <m.shulhan@gmail.com> | 2016-02-19 02:33:40 +0700 |
|---|---|---|
| committer | Shulhan <m.shulhan@gmail.com> | 2020-01-25 14:13:01 +0700 |
| commit | 28e25819f06fba23e858335a4f8924cf3d9d4ab2 (patch) | |
| tree | 8a36c18cfbeb99bd74bdfed58f4e0114915d2b41 | |
| parent | 0f1472355b317bdf488d8e6d190e069e91d7f567 (diff) | |
| download | golang-id-tour-28e25819f06fba23e858335a4f8924cf3d9d4ab2.tar.xz | |
Sync with golang/tour@9616eac69404c8d4aab36bf42624b08e2e8dffd2
Translate comment and text in code examples.
| -rw-r--r-- | content/basics/imports.go | 2 | ||||
| -rw-r--r-- | content/basics/numeric-constants.go | 7 | ||||
| -rw-r--r-- | content/basics/packages.go | 2 | ||||
| -rw-r--r-- | content/basics/type-inference.go | 4 | ||||
| -rw-r--r-- | content/concurrency/exercise-web-crawler.go | 12 | ||||
| -rw-r--r-- | content/concurrency/mutex-counter.go | 12 | ||||
| -rw-r--r-- | content/flowcontrol/switch-evaluation-order.go | 10 | ||||
| -rw-r--r-- | content/flowcontrol/switch-with-no-condition.go | 6 | ||||
| -rw-r--r-- | content/flowcontrol/switch.go | 2 | ||||
| -rw-r--r-- | content/methods/errors.go | 2 | ||||
| -rw-r--r-- | content/methods/interfaces-are-satisfied-implicitly.go | 4 | ||||
| -rw-r--r-- | content/methods/interfaces.go | 8 | ||||
| -rw-r--r-- | content/methods/methods-with-pointer-receivers.go | 4 | ||||
| -rw-r--r-- | content/methods/type-switches.go | 6 | ||||
| -rw-r--r-- | content/moretypes/append.go | 6 | ||||
| -rw-r--r-- | content/moretypes/exercise-fibonacci-closure.go | 4 | ||||
| -rw-r--r-- | content/moretypes/pointers.go | 14 | ||||
| -rw-r--r-- | content/moretypes/slices-of-slice.go | 6 | ||||
| -rw-r--r-- | content/moretypes/struct-literals.go | 8 | ||||
| -rw-r--r-- | content/welcome/sandbox.go | 4 |
20 files changed, 63 insertions, 60 deletions
diff --git a/content/basics/imports.go b/content/basics/imports.go index 8424aca..df205dd 100644 --- a/content/basics/imports.go +++ b/content/basics/imports.go @@ -8,5 +8,5 @@ import ( ) func main() { - fmt.Printf("Now you have %g problems.\n", math.Sqrt(7)) + fmt.Printf("Sekarang anda memiliki %g masalah.\n", math.Sqrt(7)) } diff --git a/content/basics/numeric-constants.go b/content/basics/numeric-constants.go index 59784b5..9e089c3 100644 --- a/content/basics/numeric-constants.go +++ b/content/basics/numeric-constants.go @@ -5,10 +5,11 @@ package main import "fmt" const ( - // Create a huge number by shifting a 1 bit left 100 places. - // In other words, the binary number that is 1 followed by 100 zeroes. + // Buat bilangan yang besar dengan men-shift 1 bit ke kiri 100 kali. + // Dengan kata lain, bilangan binari 1 diikuti dengan 100 angka nol. Big = 1 << 100 - // Shift it right again 99 places, so we end up with 1<<1, or 2. + // Shift kembali ke kanan sebanyak 99 kali, sehingga akhirnya menjadi + // 1<<1, atau 2 Small = Big >> 99 ) diff --git a/content/basics/packages.go b/content/basics/packages.go index 8b5ddac..7a48838 100644 --- a/content/basics/packages.go +++ b/content/basics/packages.go @@ -8,5 +8,5 @@ import ( ) func main() { - fmt.Println("My favorite number is", rand.Intn(10)) + fmt.Println("Bilangan kesukaan saya adalah", rand.Intn(10)) } diff --git a/content/basics/type-inference.go b/content/basics/type-inference.go index b311933..c408a69 100644 --- a/content/basics/type-inference.go +++ b/content/basics/type-inference.go @@ -5,6 +5,6 @@ package main import "fmt" func main() { - v := 42 // change me! - fmt.Printf("v is of type %T\n", v) + v := 42 // ubahlah nilai v! + fmt.Printf("v bertipe %T\n", v) } diff --git a/content/concurrency/exercise-web-crawler.go b/content/concurrency/exercise-web-crawler.go index c426e05..d342aa1 100644 --- a/content/concurrency/exercise-web-crawler.go +++ b/content/concurrency/exercise-web-crawler.go @@ -7,13 +7,13 @@ import ( ) type Fetcher interface { - // Fetch returns the body of URL and - // a slice of URLs found on that page. + // Fetch mengembalikan isi dari URL dan daftar URL yang ditemukan + // di halaman tersebut. Fetch(url string) (body string, urls []string, err error) } -// Crawl uses fetcher to recursively crawl -// pages starting with url, to a maximum of depth. +// Crawl menggunakan fetcher untuk secara rekursif mengambil semua halaman +// dimulai dari url, sampai kedalaman maksimum `depth`. func Crawl(url string, depth int, fetcher Fetcher) { // TODO: Fetch URLs in parallel. // TODO: Don't fetch the same URL twice. @@ -37,7 +37,7 @@ func main() { Crawl("https://golang.org/", 4, fetcher) } -// fakeFetcher is Fetcher that returns canned results. +// fakeFetcher adalah Fetcher yang mengembalikan hasil dari tampungan. type fakeFetcher map[string]*fakeResult type fakeResult struct { @@ -52,7 +52,7 @@ func (f fakeFetcher) Fetch(url string) (string, []string, error) { return "", nil, fmt.Errorf("not found: %s", url) } -// fetcher is a populated fakeFetcher. +// fetcher adalah pengembangan dari fakeFetcher. var fetcher = fakeFetcher{ "https://golang.org/": &fakeResult{ "The Go Programming Language", diff --git a/content/concurrency/mutex-counter.go b/content/concurrency/mutex-counter.go index b1483d6..4983d60 100644 --- a/content/concurrency/mutex-counter.go +++ b/content/concurrency/mutex-counter.go @@ -8,24 +8,26 @@ import ( "time" ) -// SafeCounter is safe to use concurrently. +// SafeCounter aman digunakan secara konkuren. type SafeCounter struct { mu sync.Mutex v map[string]int } -// Inc increments the counter for the given key. +// Inc meningkatkan nilai dari key. func (c *SafeCounter) Inc(key string) { c.mu.Lock() - // Lock so only one goroutine at a time can access the map c.v. + // Lock sehingga hanya satu goroutine pada satu waktu yang dapat + // mengakses map c.v. c.v[key]++ c.mu.Unlock() } -// Value returns the current value of the counter for the given key. +// Value mengembalikan nilai dari key. func (c *SafeCounter) Value(key string) int { c.mu.Lock() - // Lock so only one goroutine at a time can access the map c.v. + // Lock sehingga hanya satu gorouting pada satu waktu yang dapat + // mengakses map c.v. defer c.mu.Unlock() return c.v[key] } diff --git a/content/flowcontrol/switch-evaluation-order.go b/content/flowcontrol/switch-evaluation-order.go index 71eb3c3..5020e52 100644 --- a/content/flowcontrol/switch-evaluation-order.go +++ b/content/flowcontrol/switch-evaluation-order.go @@ -8,16 +8,16 @@ import ( ) func main() { - fmt.Println("When's Saturday?") + fmt.Println("Kapan hari Sabtu?") today := time.Now().Weekday() switch time.Saturday { case today + 0: - fmt.Println("Today.") + fmt.Println("Sekarang.") case today + 1: - fmt.Println("Tomorrow.") + fmt.Println("Besok.") case today + 2: - fmt.Println("In two days.") + fmt.Println("Dua hari lagi.") default: - fmt.Println("Too far away.") + fmt.Println("Masih jauh.") } } diff --git a/content/flowcontrol/switch-with-no-condition.go b/content/flowcontrol/switch-with-no-condition.go index e9f001c..4cc9d40 100644 --- a/content/flowcontrol/switch-with-no-condition.go +++ b/content/flowcontrol/switch-with-no-condition.go @@ -11,10 +11,10 @@ func main() { t := time.Now() switch { case t.Hour() < 12: - fmt.Println("Good morning!") + fmt.Println("Selamat pagi!") case t.Hour() < 17: - fmt.Println("Good afternoon.") + fmt.Println("Selamat sore.") default: - fmt.Println("Good evening.") + fmt.Println("Selamat malam.") } } diff --git a/content/flowcontrol/switch.go b/content/flowcontrol/switch.go index 065db3d..438c983 100644 --- a/content/flowcontrol/switch.go +++ b/content/flowcontrol/switch.go @@ -8,7 +8,7 @@ import ( ) func main() { - fmt.Print("Go runs on ") + fmt.Print("Go berjalan pada ") switch os := runtime.GOOS; os { case "darwin": fmt.Println("OS X.") diff --git a/content/methods/errors.go b/content/methods/errors.go index 7ea0aed..614e03b 100644 --- a/content/methods/errors.go +++ b/content/methods/errors.go @@ -20,7 +20,7 @@ func (e *MyError) Error() string { func run() error { return &MyError{ time.Now(), - "it didn't work", + "tidak bekerja!", } } diff --git a/content/methods/interfaces-are-satisfied-implicitly.go b/content/methods/interfaces-are-satisfied-implicitly.go index 23f4539..9cc9bd3 100644 --- a/content/methods/interfaces-are-satisfied-implicitly.go +++ b/content/methods/interfaces-are-satisfied-implicitly.go @@ -12,8 +12,8 @@ type T struct { S string } -// This method means type T implements the interface I, -// but we don't need to explicitly declare that it does so. +// Method berikut berarti type T mengimplementasikan interface I, +// tapi kita tidak perlu secara eksplisit mendeklarasikannya. func (t T) M() { fmt.Println(t.S) } diff --git a/content/methods/interfaces.go b/content/methods/interfaces.go index a6eda32..d059f9f 100644 --- a/content/methods/interfaces.go +++ b/content/methods/interfaces.go @@ -16,11 +16,11 @@ func main() { f := MyFloat(-math.Sqrt2) v := Vertex{3, 4} - a = f // a MyFloat implements Abser - a = &v // a *Vertex implements Abser + a = f // a MyFloat mengimplementasikan Abser + a = &v // a *Vertex mengimplementasikan Abser - // In the following line, v is a Vertex (not *Vertex) - // and does NOT implement Abser. + // Pada baris berikut, v adalah sebuah Vertex (bukan *Vertex) + // dan TIDAK mengimplementasikan Abser. a = v fmt.Println(a.Abs()) diff --git a/content/methods/methods-with-pointer-receivers.go b/content/methods/methods-with-pointer-receivers.go index 28acc2b..d93ccde 100644 --- a/content/methods/methods-with-pointer-receivers.go +++ b/content/methods/methods-with-pointer-receivers.go @@ -22,7 +22,7 @@ func (v *Vertex) Abs() float64 { func main() { v := &Vertex{3, 4} - fmt.Printf("Before scaling: %+v, Abs: %v\n", v, v.Abs()) + fmt.Printf("Sebelum scaling: %+v, Abs: %v\n", v, v.Abs()) v.Scale(5) - fmt.Printf("After scaling: %+v, Abs: %v\n", v, v.Abs()) + fmt.Printf("Setelah scaling: %+v, Abs: %v\n", v, v.Abs()) } diff --git a/content/methods/type-switches.go b/content/methods/type-switches.go index 12d879d..9e0f4be 100644 --- a/content/methods/type-switches.go +++ b/content/methods/type-switches.go @@ -7,11 +7,11 @@ import "fmt" func do(i interface{}) { switch v := i.(type) { case int: - fmt.Printf("Twice %v is %v\n", v, v*2) + fmt.Printf("Dua kali %v adalah %v\n", v, v*2) case string: - fmt.Printf("%q is %v bytes long\n", v, len(v)) + fmt.Printf("%q adalah %v bytes panjangnya\n", v, len(v)) default: - fmt.Printf("I don't know about type %T!\n", v) + fmt.Printf("Saya tidak tipe %T!\n", v) } } diff --git a/content/moretypes/append.go b/content/moretypes/append.go index f13b9d6..3e33d98 100644 --- a/content/moretypes/append.go +++ b/content/moretypes/append.go @@ -8,15 +8,15 @@ func main() { var s []int printSlice(s) - // append works on nil slices. + // append bekerja pada slice yang nil. s = append(s, 0) printSlice(s) - // The slice grows as needed. + // Slice bertambah seperlunya. s = append(s, 1) printSlice(s) - // We can add more than one element at a time. + // Kita juga bisa menambahkan lebih dari satu elemen sekaligus. s = append(s, 2, 3, 4) printSlice(s) } diff --git a/content/moretypes/exercise-fibonacci-closure.go b/content/moretypes/exercise-fibonacci-closure.go index dbed61f..f5125e3 100644 --- a/content/moretypes/exercise-fibonacci-closure.go +++ b/content/moretypes/exercise-fibonacci-closure.go @@ -4,8 +4,8 @@ package main import "fmt" -// fibonacci merupakan fungsi yang mengembalikan -// sebuah fungsi dengan nilai balik sebuah int. +// fibonacci adalah sebuah fungsi yang mengembalikan sebuah fungsi yang +// mengembalikan sebuah integer. func fibonacci() func() int { } diff --git a/content/moretypes/pointers.go b/content/moretypes/pointers.go index 9909b3c..09e8aca 100644 --- a/content/moretypes/pointers.go +++ b/content/moretypes/pointers.go @@ -7,12 +7,12 @@ import "fmt" func main() { i, j := 42, 2701 - p := &i // point to i - fmt.Println(*p) // read i through the pointer - *p = 21 // set i through the pointer - fmt.Println(i) // see the new value of i + p := &i // menunjuk ke i + fmt.Println(*p) // baca i lewat pointer + *p = 21 // set i lewat pointer + fmt.Println(i) // lihat nilai terbaru dari i - p = &j // point to j - *p = *p / 37 // divide j through the pointer - fmt.Println(j) // see the new value of j + p = &j // p menunjuk ke j + *p = *p / 37 // bagi nilai j lewat pointer + fmt.Println(j) // lihat nilai terbaru dari j } diff --git a/content/moretypes/slices-of-slice.go b/content/moretypes/slices-of-slice.go index 8f5cbc8..35e5b87 100644 --- a/content/moretypes/slices-of-slice.go +++ b/content/moretypes/slices-of-slice.go @@ -8,17 +8,17 @@ import ( ) func main() { - // Create a tic-tac-toe board. + // Buat papan tic-tac-toe board := [][]string{ []string{"_", "_", "_"}, []string{"_", "_", "_"}, []string{"_", "_", "_"}, } - // The players take turns. + // Giliran untuk para pemain board[0][0] = "X" board[2][2] = "O" - board[1][2] = "X" + board[2][0] = "X" board[1][0] = "O" board[0][2] = "X" diff --git a/content/moretypes/struct-literals.go b/content/moretypes/struct-literals.go index 5a96b2c..4c86016 100644 --- a/content/moretypes/struct-literals.go +++ b/content/moretypes/struct-literals.go @@ -9,10 +9,10 @@ type Vertex struct { } var ( - v1 = Vertex{1, 2} // has type Vertex - v2 = Vertex{X: 1} // Y:0 is implicit - v3 = Vertex{} // X:0 and Y:0 - p = &Vertex{1, 2} // has type *Vertex + v1 = Vertex{1, 2} // memiliki tipe Vertex + v2 = Vertex{X: 1} // Y:0 adalah implisit + v3 = Vertex{} // X:0 dan Y:0 + p = &Vertex{1, 2} // memiliki tipe *Vertex ) func main() { diff --git a/content/welcome/sandbox.go b/content/welcome/sandbox.go index 398a9ef..d93d542 100644 --- a/content/welcome/sandbox.go +++ b/content/welcome/sandbox.go @@ -8,7 +8,7 @@ import ( ) func main() { - fmt.Println("Welcome to the playground!") + fmt.Println("Selamat datang di playground!") - fmt.Println("The time is", time.Now()) + fmt.Println("Waktu sekarang adalah", time.Now()) } |
