aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--.prettierignore1
-rw-r--r--Makefile8
-rw-r--r--README.md70
-rw-r--r--app.yaml11
-rw-r--r--content/basics.article225
-rw-r--r--content/basics/imports.go2
-rw-r--r--content/basics/numeric-constants.go7
-rw-r--r--content/basics/packages.go2
-rw-r--r--content/basics/type-inference.go4
-rw-r--r--content/concurrency.article228
-rw-r--r--content/concurrency/exercise-equivalent-binary-trees.go2
-rw-r--r--content/concurrency/exercise-web-crawler.go12
-rw-r--r--content/concurrency/mutex-counter.go12
-rw-r--r--content/flowcontrol.article206
-rw-r--r--content/flowcontrol/if-and-else.go2
-rw-r--r--content/flowcontrol/switch-evaluation-order.go10
-rw-r--r--content/flowcontrol/switch-with-no-condition.go6
-rw-r--r--content/flowcontrol/switch.go2
-rw-r--r--content/methods.article447
-rw-r--r--content/methods/errors.go2
-rw-r--r--content/methods/exercise-images.go2
-rw-r--r--content/methods/exercise-reader.go2
-rw-r--r--content/methods/interfaces-are-satisfied-implicitly.go4
-rw-r--r--content/methods/interfaces.go8
-rw-r--r--content/methods/methods-with-pointer-receivers.go4
-rw-r--r--content/methods/type-switches.go6
-rw-r--r--content/moretypes.article329
-rw-r--r--content/moretypes/append.go6
-rw-r--r--content/moretypes/exercise-fibonacci-closure.go4
-rw-r--r--content/moretypes/exercise-maps.go2
-rw-r--r--content/moretypes/exercise-slices.go2
-rw-r--r--content/moretypes/pointers.go14
-rw-r--r--content/moretypes/slices-of-slice.go4
-rw-r--r--content/moretypes/struct-literals.go8
-rw-r--r--content/welcome.article146
-rw-r--r--content/welcome/sandbox.go4
-rw-r--r--go.mod16
-rw-r--r--go.sum41
-rw-r--r--local.go13
-rw-r--r--pic/pic.go19
-rw-r--r--reader/validate.go2
-rw-r--r--solutions/binarytrees.go2
-rw-r--r--solutions/binarytrees_quit.go2
-rw-r--r--solutions/image.go2
-rw-r--r--solutions/maps.go2
-rw-r--r--solutions/readers.go2
-rw-r--r--solutions/slices.go2
-rw-r--r--[-rwxr-xr-x]static/css/app.css12
-rw-r--r--[-rwxr-xr-x]static/js/app.js0
-rw-r--r--[-rwxr-xr-x]static/js/controllers.js0
-rw-r--r--[-rwxr-xr-x]static/js/directives.js0
-rw-r--r--[-rwxr-xr-x]static/js/services.js0
-rw-r--r--static/js/values.js56
-rw-r--r--static/partials/editor.html6
-rw-r--r--static/partials/list.html2
-rwxr-xr-xtemplate/index.tmpl2
-rw-r--r--tour.go2
-rw-r--r--tree/tree.go2
-rw-r--r--wc/wc.go2
60 files changed, 1124 insertions, 869 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..2f065c3
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+/index.yaml
+/tour
diff --git a/.prettierignore b/.prettierignore
new file mode 100644
index 0000000..bb0f0fa
--- /dev/null
+++ b/.prettierignore
@@ -0,0 +1 @@
+/static/js/values.js
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..1becce3
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,8 @@
+.PHONY: serve deploy
+
+serve:
+ go run .
+
+deploy:
+ gcloud config configurations activate personal
+ gcloud --project=go-tour-id2 app deploy --promote app.yaml
diff --git a/README.md b/README.md
index a186565..14eca02 100644
--- a/README.md
+++ b/README.md
@@ -1,65 +1,59 @@
# Go Tour
-[![Go Reference](https://pkg.go.dev/badge/golang.org/x/tour.svg)](https://pkg.go.dev/golang.org/x/tour)
+[![Go Reference](https://pkg.go.dev/badge/github.com/golang-id/tour.svg)](https://pkg.go.dev/github.com/golang-id/tour)
-A Tour of Go is an introduction to the Go programming language. Visit
-https://tour.golang.org to start the tour.
+Tur Bahasa Pemrograman Go adalah sebuah situs pengenalan untuk bahasa
+pemrograman Go.
+Kunjungi situs https://tour.golang-id.org untuk memulai tur.
-## Download/Install
+## Unduh/Pasang
-To install the tour from source, first
-[install Go](https://golang.org/doc/install) and then run:
+Untuk memasang tur dari sumber kode, pertama
+[siapkan sebuah _workspace_](https://golang.org/doc/code.html)
+dan kemudian jalankan:
- $ go get golang.org/x/tour
+ $ go get github.com/golang-id/tour
-This will place a `tour` binary in your
-[workspace](https://golang.org/doc/code.html#Workspaces)'s `bin` directory.
-The tour program can be run offline.
+Perintah tersebut akan membuat program `tour` dalam direktori `bin` di
+_workspace_ anda, yang dapat dijalankan di lokal.
-## Contributing
+## Berkontribusi
-Contributions should follow the same procedure as for the Go project:
+Kontribusi sebaiknya mengikuti prosedur yang sama dengan proyek Go:
https://golang.org/doc/contribute.html
-To run the tour server locally:
-
+Untuk menjalankan server tur di lokal:
```sh
go run .
```
-Your browser should now open. If not, please visit [http://localhost:3999/](http://localhost:3999).
-
-
-## Report Issues / Send Patches
+Peramban Anda seharusnya akan membuka halaman tur secara otomatis, jika tidak
+buka langsung di [http://localhost:3999/](http://localhost:3999).
-This repository uses Gerrit for code changes. To learn how to submit changes to
-this repository, see https://golang.org/doc/contribute.html.
+## Pelaporan Isu / Pengiriman patch
-The issue tracker for the tour's code is located at https://github.com/golang/go/issues.
-Prefix your issue with "x/tour:" in the subject line, so it is easy to find.
+Repository ini menggunakan Github untuk perubahan kode, yang bisa diakses
+lewat https://github.com/golang-id/tour/issues.
-Issues with the tour's content itself should be reported in the issue tracker
-at https://github.com/golang/tour/issues.
+## Penerbitan
-## Deploying
-
-1. To deploy tour.golang.org, run:
+1. Untuk menerbitkan tour.golang.org, jalankan:
```
- GO111MODULE=on gcloud --project=golang-org app deploy --no-promote app.yaml
+ gcloud --project=go-tour-id2 app deploy --no-promote app.yaml
```
+ Perintah tersebut akan membuat versi baru, yang dapat dilihat di
+ [golang-org GCP project](https://console.cloud.google.com/appengine/versions?project=go-tour-id2&serviceId=default).
- This will create a new version, which can be viewed within the
- [golang-org GCP project](https://console.cloud.google.com/appengine/versions?project=golang-org&serviceId=tour).
-
-2. Check that the deployed version looks OK (click the version link in GCP).
+2. Periksa apakah versi yang diterbitkan berjalan (klik pada tautan
+ version di GCP).
-3. If all is well, click "Migrate Traffic" to move 100% of the tour.golang.org
- traffic to the new version.
+3. Jika semua berjalan dengan baik, klik "Migrate Traffic" untuk
+ memindahkan 100% semua traffik ke versi yang baru.
-4. You're done.
+4. Selesai.
-## License
+## Lisensi
-Unless otherwise noted, the go-tour source files are distributed
-under the BSD-style license found in the LICENSE file.
+Kecuali bila dicantumkan, berkas sumber kode go-tour didistribusikan dengan
+lisensi model BSD yang bisa ditemukan pada berkas LICENSE.
diff --git a/app.yaml b/app.yaml
index 3af97ec..63bf198 100644
--- a/app.yaml
+++ b/app.yaml
@@ -1,15 +1,14 @@
-service: tour
-runtime: go114
+service: default
+runtime: go118
env_variables:
TOUR_ANALYTICS: |
- <script async src="https://www.googletagmanager.com/gtag/js?id=UA-11222381-5"></script>
+ <script async src="https://www.googletagmanager.com/gtag/js?id=UA-2502278-11"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
- gtag("js", new Date());
- gtag("config", "UA-11222381-5");
- gtag("config", "UA-49880327-6");
+ gtag('js', new Date());
+ gtag('config', 'UA-2502278-11');
</script>
default_expiration: "7d"
diff --git a/content/basics.article b/content/basics.article
index 082a6ab..e151efd 100644
--- a/content/basics.article
+++ b/content/basics.article
@@ -1,131 +1,153 @@
-Packages, variables, and functions.
-Learn the basic components of any Go program.
+Paket, variabel, dan fungsi.
+Belajar komponen dasar dari program Go.
-The Go Authors
+Para Penggubah Go
https://golang.org
-* Packages
+* Paket ("package")
-Every Go program is made up of packages.
+Setiap program Go terbuat dari paket-paket (`package`).
-Programs start running in package `main`.
+Program mulai berjalan dalam paket `main`.
-This program is using the packages with import paths `"fmt"` and `"math/rand"`.
+Program di sebelah menggunakan paket lain dengan meng- `import` `"fmt"` dan
+`"math/rand"`.
-By convention, the package name is the same as the last element of the import path. For instance, the `"math/rand"` package comprises files that begin with the statement `package`rand`.
+Aturannya, nama paket sama dengan elemen terakhir dari path `import`.
+Sebagai contohnya, paket `"math/rand"` terdiri dari berkas-berkas yang dimulai
+dengan perintah `package`rand`.
-#appengine: *Note:* The environment in which these programs are executed is
-#appengine: deterministic, so each time you run the example program
-#appengine: `rand.Intn` will return the same number.
-#appengine:
-#appengine: (To see a different number, seed the number generator; see [[https://golang.org/pkg/math/rand/#Seed][`rand.Seed`]].
-#appengine: Time is constant in the playground, so you will need to use something else as the seed.)
+#appengine: *Catatan:* Lingkungan di mana program di situs ini berjalan adalah
+#appengine: deterministik, sehingga setiap kali anda mengeksekusi contoh
+#appengine: program `rand.Intn` akan selalu mengembalikan angka yang sama.
+#appengine: (Untuk mendapatkan angka yang acak, tambahkan pembangkit angka;
+#appengine: lihat fungsi
+#appengine: [[https://golang.org/pkg/math/rand/#Seed][`rand.Seed`]].
+#appengine: Waktu adalah konstan di dalam _playground_, jadi anda perlu
+#appengine: menggunakan hal lain sebagai pembangkit acak.)
.play basics/packages.go
-* Imports
+* Import
-This code groups the imports into a parenthesized, "factored" import statement.
+Kode ini mengelompokan `import` di dalam tanda kurung, atau disebut juga
+perintah `import` yang "difaktorkan".
-You can also write multiple import statements, like:
+Anda juga bisa menulis perintah `import`, seperti:
import "fmt"
import "math"
-But it is good style to use the factored import statement.
+Tapi lebih disarankan untuk menggunakan perintah `import` yang difaktorkan.
.play basics/imports.go
-* Exported names
+* Nama-nama yang diekspor
-In Go, a name is exported if it begins with a capital letter.
-For example, `Pizza` is an exported name, as is `Pi`, which is exported from
-the `math` package.
+Pada bahasa Go, sebuah nama diekspor jika diawali dengan huruf besar.
+Sebagai contohnya, `Pizza` itu nama yang diekspor, sebagaimana juga `Pi`, yang
+diekspor dari paket `math`.
-`pizza` and `pi` do not start with a capital letter, so they are not exported.
+`pizza` dan `pi` tidak diawali dengan huruf besar, maka mereka tidak diekspor.
-When importing a package, you can refer only to its exported names.
-Any "unexported" names are not accessible from outside the package.
+Saat mengimpor sebuah paket, anda hanya bisa mengacu pada nama yang diekspor.
+Setiap nama yang tidak diekspor tidak akan bisa diakses dari luar paket.
-Run the code. Notice the error message.
+Jalankan kode di sebelah.
+Perhatikan akan adanya pesan kesalahan.
-To fix the error, rename `math.pi` to `math.Pi` and try it again.
+Untuk memperbaikinya, ganti nama `math.pi` dengan `math.Pi` dan coba kembali.
.play basics/exported-names.go
-* Functions
+* Fungsi
-A function can take zero or more arguments.
+Sebuah fungsi bisa tanpa argumen atau banyak argumen.
-In this example, `add` takes two parameters of type `int`.
+Pada contoh ini, `add` memiliki dua parameter dengan tipe `int`.
-Notice that the type comes _after_ the variable name.
+Perhatikan bahwa tipe berada _setelah_ nama variabel.
-(For more about why types look the way they do, see the [[https://blog.golang.org/gos-declaration-syntax][article on Go's declaration syntax]].)
+(Untuk mengetahui kenapa tipe ditulis seperti itu, lihat
+[[https://blog.golang.org/gos-declaration-syntax][artikel Go tentang deklarasi sintaks]].)
.play basics/functions.go
-* Functions continued
+* Fungsi (lanjutan)
-When two or more consecutive named function parameters share a type, you can omit the type from all but the last.
+Saat dua atau lebih parameter fungsi memiliki tipe yang sama, anda bisa
+menggabungkannya menjadi satu.
-In this example, we shortened
+Pada contoh ini, kita singkat
x int, y int
-to
+menjadi
x, y int
.play basics/functions-continued.go
-* Multiple results
+* Fungsi dengan banyak kembalian
-A function can return any number of results.
+Sebuah fungsi dapat mengeluarkan banyak kembalian.
-The `swap` function returns two strings.
+Fungsi `swap` mengembalikan dua `string`.
.play basics/multiple-results.go
-* Named return values
+* Fungsi dengan kembalian bernama
-Go's return values may be named. If so, they are treated as variables defined at the top of the function.
+Nilai kembalian dari fungsi bisa diberi nama.
+Jika nilai kembalian memiliki nama, mereka diperlakukan seperti variabel yang
+didefinisikan pada fungsi.
-These names should be used to document the meaning of the return values.
+Penamaan tersebut seharusnya digunakan untuk mendokumentasikan makna dari
+nilai kembalian.
-A `return` statement without arguments returns the named return values. This is known as a "naked" return.
+Sebuah perintah `return` tanpa nilai kembalian, mengembalikan nilai terakhir
+yang disimpan dari setiap variabel kembalian.
+Hal ini dikenal dengan kembalian "naked".
-Naked return statements should be used only in short functions, as with the example shown here. They can harm readability in longer functions.
+Perintah kembalian "naked" sebaiknya hanya digunakan pada fungsi yang singkat,
+seperti pada contoh di sebelah, karena bisa mengganggu pembacaan kode
+bila digunakan pada fungsi yang panjang.
.play basics/named-results.go
-* Variables
+* Variabel
-The `var` statement declares a list of variables; as in function argument lists, the type is last.
+Perintah `var` mendeklarasikan daftar variabel; seperti pada daftar argumen
+pada fungsi, tipenya berada di akhir.
-A `var` statement can be at package or function level. We see both in this example.
+Perintah `var` bisa ditulis pada tingkat paket atau fungsi, seperti pada
+contoh sebelah.
.play basics/variables.go
-* Variables with initializers
+* Variabel dengan inisialisasi
-A var declaration can include initializers, one per variable.
+Deklarasi sebuah variabel bisa mengikutkan inisialisasi, satu inisialisasi per
+variabel.
-If an initializer is present, the type can be omitted; the variable will take the type of the initializer.
+Jika variabel diinisialisasi, maka tipe dari variabel bisa dihilangkan;
+sehingga variabel akan memiliki tipe sesuai dengan inisialisasi.
.play basics/variables-with-initializers.go
-* Short variable declarations
+* Deklarasi variabel singkat
-Inside a function, the `:=` short assignment statement can be used in place of a `var` declaration with implicit type.
+Dalam sebuah fungsi, perintah singkat `:=` bisa digunakan menggantikan `var`
+dengan tipe implisit.
-Outside a function, every statement begins with a keyword (`var`, `func`, and so on) and so the `:=` construct is not available.
+Di luar sebuah fungsi, setiap perintah harus dimulai dengan kata kunci (`var`,
+`func`, dst), sehingga `:=` tidak bisa digunakan.
.play basics/short-variable-declarations.go
-* Basic types
+* Tipe dasar
-Go's basic types are
+Tipe dasar pada Go yaitu,
bool
@@ -134,102 +156,115 @@ Go's basic types are
int int8 int16 int32 int64
uint uint8 uint16 uint32 uint64 uintptr
- byte // alias for uint8
+ byte // alias untuk uint8
- rune // alias for int32
- // represents a Unicode code point
+ rune // alias untuk int32
+ // merepresentasikan sebuah kode Unicode
float32 float64
complex64 complex128
-The example shows variables of several types,
-and also that variable declarations may be "factored" into blocks,
-as with import statements.
+Contoh sebelah memperlihatkan variabel dengan beberapa tipe, dan juga
+deklarasi variabel bisa "difaktorkan" ke dalam blok, seperti pada perintah
+`import`.
-The `int`, `uint`, and `uintptr` types are usually 32 bits wide on 32-bit systems and 64 bits wide on 64-bit systems.
-When you need an integer value you should use `int` unless you have a specific reason to use a sized or unsigned integer type.
+Tipe `int`, `uint`, dan `uintptr` biasanya memiliki panjang 32 bits pada
+sistem 32-bit dan 64 bits pada sistem 64-bit.
+Saat anda membutuhkan nilai integer anda sebaiknya menggunakan tipe `int`
+kecuali anda memiliki alasan tertentu menggunakan tipe berukuran khusus atau
+_unsigned_integer_.
.play basics/basic-types.go
-* Zero values
+* Nilai kosong
-Variables declared without an explicit initial value are given their
-_zero_value_.
+Variabel yang dideklarasikan tanpa nilai awal diberikan _nilai_kosong_.
-The zero value is:
+Nilai kosong adalah:
-- `0` for numeric types,
-- `false` for the boolean type, and
-- `""` (the empty string) for strings.
+- `0` untuk tipe numerik,
+- `false` untuk tipe boolean, dan
+- `""` (string kosong) untuk string.
.play basics/zero.go
-* Type conversions
+* Konversi Tipe
-The expression `T(v)` converts the value `v` to the type `T`.
+Ekspresi `T(v)` mengkonversi nilai `v` ke tipe `T`.
-Some numeric conversions:
+Beberapa konversi numerik:
var i int = 42
var f float64 = float64(i)
var u uint = uint(f)
-Or, put more simply:
+Atau, sederhananya:
i := 42
f := float64(i)
u := uint(f)
-Unlike in C, in Go assignment between items of different type requires an
-explicit conversion.
-Try removing the `float64` or `uint` conversions in the example and see what happens.
+Tidak seperti C, perintah pengisian nilai pada Go antara item dengan tipe
+berbeda membutuhkan konversi eksplisit.
+Coba hilangkan konversi `float64` atau `int` pada contoh sebelah dan lihat apa
+yang terjadi.
.play basics/type-conversions.go
-* Type inference
+* Inferensi tipe
-When declaring a variable without specifying an explicit type (either by using the `:=` syntax or `var`=` expression syntax), the variable's type is inferred from the value on the right hand side.
+Saat mendeklarasikan sebuah variabel tanpa menentukan tipe eksplisitnya (baik
+menggunakan sintaks `:=` atau `var`), tipe variabel disamakan dengan nilai di
+sebelah kanannya.
-When the right hand side of the declaration is typed, the new variable is of that same type:
+Bila sisi kanan dari deklarasi ditulis tipenya, maka variabel baru memiliki
+tipe yang sama:
var i int
- j := i // j is an int
+ j := i // j adalah sebuah int
-But when the right hand side contains an untyped numeric constant, the new variable may be an `int`, `float64`, or `complex128` depending on the precision of the constant:
+Tapi bila sisi kanan berupa konstanta numerik, variabel baru bisa jadi `int`,
+`float64`, atau `complex128` bergantung kepada presisi dari konstanta:
i := 42 // int
f := 3.142 // float64
g := 0.867 + 0.5i // complex128
-Try changing the initial value of `v` in the example code and observe how its type is affected.
+Coba ubah nilai awal dari `v` pada contoh kode dan perhatikan bagaimana
+tipenya berubah.
.play basics/type-inference.go
-* Constants
+* Konstanta
-Constants are declared like variables, but with the `const` keyword.
+Konstanta dideklarasikan seperti variabel, tapi dengan kata `const`.
-Constants can be character, string, boolean, or numeric values.
+Konstanta bisa bernilai karakter, string, boolean, atau numerik.
-Constants cannot be declared using the `:=` syntax.
+Konstanta tidak bisa dideklarasikan dengan sintaks `:=`.
.play basics/constants.go
-* Numeric Constants
+* Konstanta Numerik
-Numeric constants are high-precision _values_.
+Konstanta numerik adalah _nilai_ dengan presisi-tinggi.
-An untyped constant takes the type needed by its context.
+Konstanta yang tidak bertipe menggunakan tipe yang dibutuhkan sesuai dengan
+konteksnya.
-Try printing `needInt(Big)` too.
+Coba cetak juga `needInt(Big)`.
-(An `int` can store at maximum a 64-bit integer, and sometimes less.)
+(Sebuah `int` dapat menyimpan sebanyak 64-bit integer, dan terkadang lebih
+sedikit, bergantung kepada mesin anda.)
.play basics/numeric-constants.go
-* Congratulations!
+* Selamat!
-You finished this lesson!
+Anda telah menyelesaikan pelajaran ini!
-You can go back to the list of [[/list][modules]] to find what to learn next, or continue with the [[javascript:click('.next-page')][next lesson]].
+Anda bisa kembali ke daftar
+[[/list][modul]]
+untuk melihat apa yang bisa dipelajari selanjutnya, atau terus ke
+[[javascript:click(".next-page")][pelajaran selanjutnya]].
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.article b/content/concurrency.article
index 9cb5f69..5aba00e 100644
--- a/content/concurrency.article
+++ b/content/concurrency.article
@@ -1,87 +1,114 @@
-Concurrency
-Go provides concurrency constructions as part of the core language. This lesson presents them and gives some examples on how they can be used.
+Konkurensi
+Go menyediakan konstruksi konkurensi sebagai bagian dari inti bahasanya. Pelajaran kali ini menjelaskan dan memberikan beberapa contoh penggunaannya.
-The Go Authors
+Para Penggubah Go
https://golang.org
* Goroutines
-A _goroutine_ is a lightweight thread managed by the Go runtime.
+Sebuah _goroutine_ yaitu suatu thread ringan yang diatur oleh Go runtime.
+Perintah
go f(x, y, z)
-starts a new goroutine running
+memulai sebuah goroutine baru `f` dengan menjalankan
f(x, y, z)
-The evaluation of `f`, `x`, `y`, and `z` happens in the current goroutine and the execution of `f` happens in the new goroutine.
+Evaluasi dari nilai `f`, `x`, `y`, dan `z` terjadi di goroutine yang memanggil
+dan eksekusi dari `f` terjadi di goroutine yang baru.
-Goroutines run in the same address space, so access to shared memory must be synchronized. The [[https://golang.org/pkg/sync/][`sync`]] package provides useful primitives, although you won't need them much in Go as there are other primitives. (See the next slide.)
+Goroutine berjalan di ruang alamat yang sama, sehingga akses ke
+_shared_memory_ harus disinkronisasi.
+Paket
+[[https://golang.org/pkg/sync/][`sync`]]
+menyediakan fungsi primitif untuk sinkronisasi, walaupun anda tidak terlalu
+membutuhkannya karena ada fungsi primitif lainnya.
+(Lihat slide selanjutnya.)
.play concurrency/goroutines.go
-* Channels
+* Kanal
-Channels are a typed conduit through which you can send and receive values with the channel operator, `<-`.
+Kanal adalah sebuah penghubung tipe, yang mana anda bisa mengirim dan menerima
+nilai dengan operator kanal, `<-`.
- ch <- v // Send v to channel ch.
- v := <-ch // Receive from ch, and
- // assign value to v.
+ ch <- v // Kirim v ke kanal ch.
+ v := <-ch // Terima dari ch, dan simpan nilainya ke v.
-(The data flows in the direction of the arrow.)
+(Aliran data sesuai dengan arah panah.)
-Like maps and slices, channels must be created before use:
+Seperti map dan slice, kanal harus dibuat sebelum digunakan:
ch := make(chan int)
-By default, sends and receives block until the other side is ready. This allows goroutines to synchronize without explicit locks or condition variables.
+Secara bawaan, pengiriman dan penerimaan ditahan sampai sisi yang lain siap.
+Hal ini membolehkan goroutine untuk melakukan sinkronisasi tanpa melakukan
+penguncian secara eksplisit atau menggunakan variabel kondisi.
-The example code sums the numbers in a slice, distributing the work between two goroutines.
-Once both goroutines have completed their computation, it calculates the final result.
+Contoh kode menjumlahkan angka yang ada di `slice`, dengan mendistribusikan
+kerja antara dua goroutine.
+Saat kedua goroutine selesai, hasil akhirnya kemudian akan dihitung.
.play concurrency/channels.go
-* Buffered Channels
+* Kanal dengan buffer
-Channels can be _buffered_. Provide the buffer length as the second argument to `make` to initialize a buffered channel:
+Kanal memiliki _buffer_.
+Cukup dengan menambahkan panjang buffer ke argumen kedua pada `make` untuk
+menginisialisasi buffer kanal:
ch := make(chan int, 100)
-Sends to a buffered channel block only when the buffer is full. Receives block when the buffer is empty.
+Pengiriman ke kanal buffer akan ditahan bila buffer telah penuh.
+Penerimaan akan ditahan saat buffer kosong.
-Modify the example to overfill the buffer and see what happens.
+Ubahlah contoh untuk memenuhi buffer dan lihat apa yang terjadi.
.play concurrency/buffered-channels.go
-* Range and Close
+* "range" dan "close"
-A sender can `close` a channel to indicate that no more values will be sent. Receivers can test whether a channel has been closed by assigning a second parameter to the receive expression: after
+Pengirim dapat menutup (`close`) sebuah kanal untuk menandakan bahwa tidak ada
+lagi data yang dikirim.
+Penerima dapat memeriksa apakah kanal telah ditutup dengan menambahkan
+parameter kedua pada ekspresi penerimaan:
v, ok := <-ch
-`ok` is `false` if there are no more values to receive and the channel is closed.
+`ok` bernilai `false` jika tidak ada lagi nilai yang diterima dan kanal telah
+ditutup.
-The loop `for`i`:=`range`c` receives values from the channel repeatedly until it is closed.
+Pengulangan `for`i`:=`range`c` menerima nilai dari kanal berulang kali sampai
+ditutup.
-*Note:* Only the sender should close a channel, never the receiver. Sending on a closed channel will cause a panic.
+*Catatan:* Hanya pengirim yang sebaiknya menutup kanal, bukan si penerima.
+Mengirim ke kanal yang telah tertutup akan menyebabkan `panic`.
-*Another*note:* Channels aren't like files; you don't usually need to close them. Closing is only necessary when the receiver must be told there are no more values coming, such as to terminate a `range` loop.
+*Catatan*lain:* Kanal tidak seperti file; yang mana anda tidak selalu perlu
+menutupnya.
+Penutupan hanya diperlukan saat penerima harus diberitahu bahwa tidak ada lagi
+nilai yang akan diterima, misalnya untuk menghentikan pengulangan pada
+`range`.
.play concurrency/range-and-close.go
-* Select
+* Perintah "select"
-The `select` statement lets a goroutine wait on multiple communication operations.
+Perintah `select` membuat sebuah goroutine menunggu beberapa operasi
+komunikasi.
-A `select` blocks until one of its cases can run, then it executes that case. It chooses one at random if multiple are ready.
+`select` menahan pembacaan sampai salah satu kondisinya dapat berjalan,
+kemudian ia mengeksekusi kondisi tersebut.
+Ia memilih salah satu kondisi secara acak jika banyak kondisi telah siap.
.play concurrency/select.go
-* Default Selection
+* Seleksi "default"
-The `default` case in a `select` is run if no other case is ready.
+Kondisi `default` pada `select` dijalankan jika tidak ada kondisi yang siap.
-Use a `default` case to try a send or receive without blocking:
+Gunakan kondisi `default` untuk mencoba mengirim dan menerima tanpa diblok:
select {
case i := <-c:
@@ -92,15 +119,22 @@ Use a `default` case to try a send or receive without blocking:
.play concurrency/default-selection.go
-* Exercise: Equivalent Binary Trees
+* Latihan: Binary Tree yang sama
-There can be many different binary trees with the same sequence of values stored in it. For example, here are two binary trees storing the sequence 1, 1, 2, 3, 5, 8, 13.
+Ada banyak cara membangun sebuah _binary_tree_ dengan urutan nilai yang sama
+tersimpan di dalamnya.
+Sebagai contohnya, berikut dua _binary_tree_ yang menyimpan urutan 1, 1, 2, 3,
+5, 8, 13.
.image /content/img/tree.png
-A function to check whether two binary trees store the same sequence is quite complex in most languages. We'll use Go's concurrency and channels to write a simple solution.
+Sebuah fungsi yang memeriksa apakah dua binary tree menyimpan urutan yang
+sama, akan cukup kompleks bila diiimplementasikan pada kebanyakan bahasa
+pemrograman.
+Kita akan gunakan konkurensi dan kanal untuk menulis sebuah solusi sederhana
+menggunakan Go.
-This example uses the `tree` package, which defines the type:
+Contoh ini menggunakan paket `tree`, yang mendefinisikan tipe:
type Tree struct {
Left *Tree
@@ -109,100 +143,118 @@ This example uses the `tree` package, which defines the type:
}
-Continue description on [[javascript:click('.next-page')][next page]].
+Lanjutkan deskripsi pada [[javascript:click(".next-page")][halaman selanjutnya]].
-* Exercise: Equivalent Binary Trees
+* Latihan: Binary Tree yang sama
-*1.* Implement the `Walk` function.
+*1.* Implementasikan fungsi `Walk`.
-*2.* Test the `Walk` function.
+*2.* Uji fungsi `Walk`.
-The function `tree.New(k)` constructs a randomly-structured (but always sorted) binary tree holding the values `k`, `2k`, `3k`, ..., `10k`.
+Fungsi `tree.New(k)` membuat binary tree yang secara acak-terstuktur (tetapi
+selalu terurut) yang menyimpan nilai `k`, `2k`, `3k`, ..., `10k`.
-Create a new channel `ch` and kick off the walker:
+Buat sebuah kanal baru `ch` dan jalankan fungsi `Walk`
go Walk(tree.New(1), ch)
-Then read and print 10 values from the channel. It should be the numbers 1, 2, 3, ..., 10.
+Kemudian baca dan cetak 10 nilai dari kanal.
+Ia harusnya mengeluarkan angka 1, 2, 3, ..., 10.
-*3.* Implement the `Same` function using `Walk` to determine whether `t1` and `t2` store the same values.
+*3.* Implementasikan fungsi `Same` menggunakan `Walk` untuk menentukan apakah
+`t1` dan `t2` menyimpan nilai yang sama.
-*4.* Test the `Same` function.
+*4.* Uji fungsi `Same`.
-`Same(tree.New(1),`tree.New(1))` should return true, and `Same(tree.New(1),`tree.New(2))` should return false.
+`Same(tree.New(1),`tree.New(1))` mengembalikan nilai `true`, dan
+`Same(tree.New(1),`tree.New(2))` mengembalikan nilai `false`.
-The documentation for `Tree` can be found [[https://godoc.org/golang.org/x/tour/tree#Tree][here]].
+Dokumentasi untuk `Tree` bisa ditemukan
+[[https://godoc.org/golang.org/x/tour/tree#Tree][di sini]].
.play concurrency/exercise-equivalent-binary-trees.go
* sync.Mutex
-We've seen how channels are great for communication among goroutines.
+Kita telah melihat bagaimana _channel_ sangat bagus untuk komunikasi antara
+beberapa _goroutine_.
-But what if we don't need communication? What if we just want to make sure only
-one goroutine can access a variable at a time to avoid conflicts?
+Namun bagaimana jika kita tidak ingin komunikasi?
+Bagaimana jika kita hanya ingin memastikan hanya satu goroutine yang dapat
+mengakses suatu variabel pada satu waktu untuk menghindari konflik?
-This concept is called _mutual_exclusion_, and the conventional name for the data structure that provides it is _mutex_.
+Konsep ini disebut juga dengan _mutual_exclusion_, dan nama umum untuk
+struktur data yang menyediakan fungsi tersebut adalah _mutex_.
-Go's standard library provides mutual exclusion with
-[[https://golang.org/pkg/sync/#Mutex][`sync.Mutex`]] and its two methods:
+Pustaka standar Go menyediakan mutual exclusion dengan
+[[https://golang.org/pkg/sync/#Mutex][`sync.Mutex`]]
+dan dua fungsinya:
- `Lock`
- `Unlock`
-We can define a block of code to be executed in mutual exclusion by surrounding it
-with a call to `Lock` and `Unlock` as shown on the `Inc` method.
+Kita bisa mendefinisikan sebuah blok kode untuk dieksekusi secara
+_mutual_exclusion_ dengan mengungkungnya dengan pemanggilan fungsi `Lock` dan
+`Unlock` seperti yang terlihat pada method `Inc`.
-We can also use `defer` to ensure the mutex will be unlocked as in the `Value` method.
+Kita juga bisa menggunakan `defer` untuk memastikan mutex akan dibuka kembali
+seperti pada method `Value`.
.play concurrency/mutex-counter.go
-* Exercise: Web Crawler
+* Latihan: Web Crawler
-In this exercise you'll use Go's concurrency features to parallelize a web crawler.
+Dalam latihan ini anda akan menggunakan fitur konkurensi Go untuk
+mem-paralelkan sebuah _web_crawler_.
-Modify the `Crawl` function to fetch URLs in parallel without fetching the same URL twice.
+Ubah fungsi `Crawl` untuk mengambil URL secara paralel tanpa ada duplikasi
+(mengambil URL yang sama dua kali).
-_Hint_: you can keep a cache of the URLs that have been fetched on a map, but maps alone are not
-safe for concurrent use!
+_Petunjuk_: anda bisa menyimpan _cache_ dari URL yang telah diambil
+menggunakan sebuah `map`, tapi `map` tidak aman untuk digunakan secara
+konkuren!
.play concurrency/exercise-web-crawler.go
-* Where to Go from here...
+* Kemana selanjutnya ...
-#appengine: You can get started by
-#appengine: [[https://golang.org/dl/][installing Go]].
+#appengine: Anda dapat memulai dengan
+#appengine: [[https://golang.org/doc/install/][memasang Go]].
-#appengine: Once you have Go installed, the
-The
-[[https://golang.org/doc/][Go Documentation]] is a great place to
-#appengine: continue.
-start.
-It contains references, tutorials, videos, and more.
+#appengine: Setelah Go terpasang,
+#appengine: [[https://golang.org/doc/][Dokumentasi Go]]
+#appengine: adalah tempat yang bagus untuk
+#appengine: melanjutkan.
+Dokumentasi tersebut berisi referensi, tutorial, video, dan banyak lagi.
-To learn how to organize and work with Go code, read [[https://golang.org/doc/code][How to Write Go Code]].
+Untuk belajar cara mengorganisir dan bekerja dengan kode Go, bacalah
+[[https://golang.org/doc/code.html][Cara Menulis Kode Go]].
-If you need help with the standard library, see the [[https://golang.org/pkg/][package reference]]. For help with the language itself, you might be surprised to find the [[https://golang.org/ref/spec][Language Spec]] is quite readable.
+Jika anda membutuhkan bantuan dengan pustaka Go, lihat
+[[https://golang.org/pkg/][referensi paket]].
+Untuk bantuan mengenai bahasa itu sendiri, anda mungkin bisa membaca
+[[https://golang.org/ref/spec][Spesifikasi Bahasa Go]].
-To further explore Go's concurrency model, watch
-[[https://www.youtube.com/watch?v=f6kdp27TYZs][Go Concurrency Patterns]]
-([[https://talks.golang.org/2012/concurrency.slide][slides]])
-and
-[[https://www.youtube.com/watch?v=QDDwwePbDtw][Advanced Go Concurrency Patterns]]
+Untuk mengeksplorasi lebih lanjut tentang model konkurensi dari Go, tontonlah
+[[https://www.youtube.com/watch?v=f6kdp27TYZs][Pola Konkurensi Go]]
+([[https://talks.golang.org/2012/concurrency.slide][slide]])
+dan
+[[https://www.youtube.com/watch?v=QDDwwePbDtw][Pola Konkurensi Go Lanjutan]]
([[https://talks.golang.org/2013/advconc.slide][slides]])
-and read the
-[[https://golang.org/doc/codewalk/sharemem/][Share Memory by Communicating]]
-codewalk.
+dan baca
+[[https://golang.org/doc/codewalk/sharemem/][Berbagi Memory dengan Komunikasi]].
-To get started writing web applications, watch
+Untuk memulai membuat aplikasi web, tontonlah
[[https://vimeo.com/53221558][A simple programming environment]]
([[https://talks.golang.org/2012/simple.slide][slides]])
-and read the
-[[https://golang.org/doc/articles/wiki/][Writing Web Applications]] tutorial.
+dan baca tutorial
+[[https://golang.org/doc/articles/wiki/][Menulis Aplikasi Web]].
-The [[https://golang.org/doc/codewalk/functions/][First Class Functions in Go]] codewalk gives an interesting perspective on Go's function types.
+Artikel
+[[https://golang.org/doc/codewalk/functions/][First Class Functions in Go]]
+memberikan perspektif menarik tentang tipe fungsi pada Go.
-The [[https://blog.golang.org/][Go Blog]] has a large archive of informative Go articles.
-
-Visit [[https://golang.org][golang.org]] for more.
+[[https://blog.golang.org/][Blognya Go]]
+memiliki sejumlah arsip artikel informatif tentang Go.
+Kunjungi [[https://golang.org][golang.org]] untuk lebih lanjut.
diff --git a/content/concurrency/exercise-equivalent-binary-trees.go b/content/concurrency/exercise-equivalent-binary-trees.go
index 56d98a7..788400b 100644
--- a/content/concurrency/exercise-equivalent-binary-trees.go
+++ b/content/concurrency/exercise-equivalent-binary-trees.go
@@ -2,7 +2,7 @@
package main
-import "golang.org/x/tour/tree"
+import "github.com/golang-id/tour/tree"
// Walk walks the tree t sending all values
// from the tree to the channel ch.
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.article b/content/flowcontrol.article
index 0f25ab4..c00d811 100644
--- a/content/flowcontrol.article
+++ b/content/flowcontrol.article
@@ -1,178 +1,202 @@
-Flow control statements: for, if, else, switch and defer
-Learn how to control the flow of your code with conditionals, loops, switches and defers.
+Perintah kontrol alur: for, if, else, switch, dan defer
+Belajar cara mengontrol alur kode dengan kondisional, pengulangan, `switch` dan `defer`.
-The Go Authors
+Para Penggubah Go
https://golang.org
-* For
+* Pengulangan ("for")
-Go has only one looping construct, the `for` loop.
+Go hanya memiliki satu perintah pengulangan yaitu `for`.
-The basic `for` loop has three components separated by semicolons:
+Dasar dari pengulangan `for` yaitu memiliki tiga komponen yang dipisahkan oleh
+titik-koma:
-- the init statement: executed before the first iteration
-- the condition expression: evaluated before every iteration
-- the post statement: executed at the end of every iteration
+- perintah awal: dieksekusi sebelum iterasi pertama
+- ekspresi kondisi: dievaluasi sebelum iterasi pertama
+- perintah akhir: dieksekusi disetiap akhir iterasi
-The init statement will often be a short variable declaration, and the
-variables declared there are visible only in the scope of the `for`
-statement.
+Perintah awal biasanya berupa deklarasi variabel singkat, dan variabel yang
+dideklarasikan tersebut hanya dapat digunakan dalam skop perintah `for`.
-The loop will stop iterating once the boolean condition evaluates to `false`.
+Pengulangan akan berhenti saat ekspresi kondisi bernilai `false`.
-*Note:* Unlike other languages like C, Java, or JavaScript there are no parentheses
-surrounding the three components of the `for` statement and the braces `{`}` are
-always required.
+*Catatan:* Tidak seperti bahasa C, Java, atau JavaScript, tidak ada tanda
+kurung yang digunakan menutupi ketiga komponen dari perintah `for` dan tanda
+kurung kurawal `{`}` selalu dibutuhkan.
.play flowcontrol/for.go
-* For continued
+* Pengulangan lanjutan
-The init and post statements are optional.
+Perintah awal dan akhir adalah opsional.
.play flowcontrol/for-continued.go
-* For is Go's "while"
+* Perintah for adalah "while"-nya Go
-At that point you can drop the semicolons: C's `while` is spelled `for` in Go.
+Dengan cara ini anda bisa menghilangkan perintah awal dan akhir, menggunakan
+hanya ekpresi kondisi sehingga `for` menjadi seperti `while` pada bahasa C.
.play flowcontrol/for-is-gos-while.go
-* Forever
+* Pengulangan selamanya
-If you omit the loop condition it loops forever, so an infinite loop is compactly expressed.
+Jika anda mengosongkan kondisi maka pengulangan akan berjalan selamanya, dengan
+ini pengulangan tanpa henti dapat diekspresikan dengan singkat.
+
+Untuk keluar dari pengulangan anda bisa menggunakan perintah `break` atau
+`return` bergantung kepada kondisi yang dibutuhkan pada program.
.play flowcontrol/forever.go
-* If
+* Kondisi ("if")
-Go's `if` statements are like its `for` loops; the expression need not be
-surrounded by parentheses `(`)` but the braces `{`}` are required.
+Perintah `if` mirip seperti pada pengulangan `for`; ekspresinya tidak harus
+ditutupi dengan tanda-kurung `(`)` namun tanda `{`}` diharuskan.
.play flowcontrol/if.go
-* If with a short statement
+* Kondisi "if" singkat
-Like `for`, the `if` statement can start with a short statement to execute before the condition.
+Seperti pada perintah `for`, perintah `if` bisa diawali dengan perintah
+singkat untuk dieksekusi sebelum kondisi.
-Variables declared by the statement are only in scope until the end of the `if`.
+Variabel yang dideklarasikan pada perintah singkat tersebut hanya berlaku
+sampai lingkup kondisi `if` berakhir.
-(Try using `v` in the last `return` statement.)
+(Coba gunakan `v` di akhir perintah `return`, dan jalankan)
.play flowcontrol/if-with-a-short-statement.go
-* If and else
+* Kondisi "if" dan "else"
-Variables declared inside an `if` short statement are also available inside any
-of the `else` blocks.
+Variabel yang dideklarasikan dalam perintah singkat `if` juga dapat digunakan
+dalam blok `else`.
-(Both calls to `pow` return their results before the call to `fmt.Println`
-in `main` begins.)
+(Pada contoh, kedua pemanggilan terhadap fungsi `pow` dieksekusi sebelum
+`main` memanggil `fmt.Println`.)
.play flowcontrol/if-and-else.go
-* Exercise: Loops and Functions
+* Latihan: Pengulangan dan Fungsi
-As a way to play with functions and loops, let's implement a square root function: given a number x, we want to find the number z for which z² is most nearly x.
+Cara sederhana untuk bermain dengan pengulangan dan fungsi yaitu dengan
+mengimplementasikan fungsi kuadrat: diberikan sebuah input bilangan x, kita
+akan cari bilangan z yang mana z² paling mendekati ke x.
-Computers typically compute the square root of x using a loop.
-Starting with some guess z, we can adjust z based on how close z² is to x,
-producing a better guess:
+Komputer biasanya menghitung akar kuadrat dari x menggunakan sebuah
+pengulangan.
+Dimulai dari nilai z, kita dapat mengatur z berdasarkan berapa dekat z²
+terhadap x, menghasilkan terkaan yang lebih mendekati:
- z -= (z*z - x) / (2*z)
+ z -= (z * z - x) / (2*z)
-Repeating this adjustment makes the guess better and better
-until we reach an answer that is as close to the actual square root as can be.
+Dengan mengulangi persamaan di atas akan membuat pencarian kita semakin
+mendekati nilai kuadrat yang sebenarnya.
-Implement this in the `func`Sqrt` provided.
-A decent starting guess for z is 1, no matter what the input.
-To begin with, repeat the calculation 10 times and print each z along the way.
-See how close you get to the answer for various values of x (1, 2, 3, ...)
-and how quickly the guess improves.
+Implementasikan persamaan tersebut dalam `func`Sqrt` yang telah disediakan.
+Nilai awal yang aman untuk z adalah 1, berapapun inputnya.
+Sebagai permulaan, ulangi perhitungan 10 kali dan cetak nilai z.
+Lihat seberapa dekat hasil perhitungan anda dengan jawaban dari beragam nilai
+x (1, 2, 3, ...) dan seberapa cepat tebakan anda diperbaiki.
-Hint: To declare and initialize a floating point value,
-give it floating point syntax or use a conversion:
+Petunjuk: untuk mendeklarasikan dan menginisialisasi nilai floating point,
+gunakan sintaks floating point atau konversi:
z := 1.0
z := float64(1)
-Next, change the loop condition to stop once the value has stopped
-changing (or only changes by a very small amount).
-See if that's more or fewer than 10 iterations.
-Try other initial guesses for z, like x, or x/2.
-How close are your function's results to the [[https://golang.org/pkg/math/#Sqrt][math.Sqrt]] in the standard library?
+Selanjutnya, ubah kondisi pengulangan untuk berhenti saat nilainya sudah tidak
+berubah lagi (atau hanya berubah dengan delta yang sangat kecil).
+Lihat apakah iterasinya lebih sedikit atau lebih banyak dari 10 iterasi.
+Coba ganti nilai terkaan awal untuk z, misalnya x, atau x/2.
+Seberapa dekat hasil anda dengan nilai
+[[https://golang.org/pkg/math/#Sqrt][`math.Sqrt`]]
+dari pustaka standar?
-(*Note:* If you are interested in the details of the algorithm, the z² − x above
-is how far away z² is from where it needs to be (x), and the division by 2z is the derivative
-of z², to scale how much we adjust z by how quickly z² is changing.
-This general approach is called [[https://en.wikipedia.org/wiki/Newton%27s_method][Newton's method]].
-It works well for many functions but especially well for square root.)
+*Catatan:* Jika anda tertarik dengan rincian dari algoritma, persamaan z² − x
+adalah seberapa jauh nilai z² dari yang diinginkan (x), dan pembagian dengan
+(2*z) adalah turunan dari z², untuk melihat berapa banyak kita harus memperbaiki
+nilai z dengan melihat berapa cepat z² berubah.
+Pendekatan ini disebut dengan
+[[https://id.wikipedia.org/wiki/Metode_Newton][metode Newton]].
+Ia bekerja dengan baik untuk beragam fungsi, terutama kuadrat.
.play flowcontrol/exercise-loops-and-functions.go
-* Switch
+* Perintah "switch"
-A `switch` statement is a shorter way to write a sequence of `if`-`else` statements.
-It runs the first case whose value is equal to the condition expression.
+Perintah switch untuk mempermudah membuat beberapa perintah kondisi
+`if`-`else`.
+Go akan menjalankan case pertama yang nilainya sama dengan ekspresi kondisi
+yang diberikan.
-Go's switch is like the one in C, C++, Java, JavaScript, and PHP,
-except that Go only runs the selected case, not all the cases that follow.
-In effect, the `break` statement that is needed at the end of each case in those
-languages is provided automatically in Go.
-Another important difference is that Go's switch cases need not
-be constants, and the values involved need not be integers.
+Perintah switch pada Go hampir sama dengan bahasa C, C++, Java, Javascript,
+dan PHP;
+hanya saja pada Go akan menjalankan case yang terpilih, bukan semua case yang
+ada selanjutnya.
+Efeknya, perintah `break` yang biasanya dibutuhkan diakhir setiap case pada
+bahasa lainnya dibuat secara otomatis oleh Go.
+Perbedaan penting lainnya yaitu ekspresi kondisi case pada Go tidak harus
+konstanta, dan nilainya tidak harus integer.
.play flowcontrol/switch.go
-* Switch evaluation order
+* Urutan evaluasi "switch"
-Switch cases evaluate cases from top to bottom, stopping when a case succeeds.
+Kondisi pada `switch` dievaluasi dari atas ke bawah, berhenti saat sebuah
+kondisi sukses.
-(For example,
+Sebagai contoh,
switch i {
case 0:
case f():
}
-does not call `f` if `i==0`.)
+tidak akan memanggil fungsi `f` jika `i==0`.
-#appengine: *Note:* Time in the Go playground always appears to start at
-#appengine: 2009-11-10 23:00:00 UTC, a value whose significance is left as an
-#appengine: exercise for the reader.
+#appengine: *Catatan:* Waktu dalam Go playground selalu berawal dari
+#appengine: 2009-11-10 23:00:00 UTC, sebuah nilai yang maknanya bisa dicari
+#appengine: oleh pembaca.
.play flowcontrol/switch-evaluation-order.go
-* Switch with no condition
+* Perintah "switch" tanpa kondisi
-Switch without a condition is the same as `switch`true`.
+Perintah `switch` tanpa sebuah kondisi sama seperti `switch`true`.
-This construct can be a clean way to write long if-then-else chains.
+Konstruksi ini merupakan cara yang bersih untuk menulis rantaian
+`if-then-else` yang panjang.
.play flowcontrol/switch-with-no-condition.go
-* Defer
+* Perintah "defer"
-A defer statement defers the execution of a function until the surrounding
-function returns.
+Perintah `defer` menunda eksekusi dari sebuah fungsi sampai fungsi yang
+melingkupinya selesai.
-The deferred call's arguments are evaluated immediately, but the function call
-is not executed until the surrounding function returns.
+Argumen untuk pemanggilan `defer` dievaluasi langsung, tapi pemanggilan fungsi
+tidak dieksekusi sampai fungsi yang melingkupinya selesai.
.play flowcontrol/defer.go
-* Stacking defers
+* Penundaan bertumpuk
-Deferred function calls are pushed onto a stack. When a function returns, its
-deferred calls are executed in last-in-first-out order.
+Fungsi yang dipanggil dengan `defer` di- _push_ ke sebuah _stack_.
+Saat fungsi berakhir, panggilan yang tadi ditunda dieksekusi dengan urutan
+last-in-first-out (yang terakhir masuk menjadi pertama keluar).
-To learn more about defer statements read this
-[[https://blog.golang.org/defer-panic-and-recover][blog post]].
+Untuk belajar lebih lanjut tentang perintah `defer` bacalah
+[[https://blog.golang.org/defer-panic-and-recover][blog berikut]].
.play flowcontrol/defer-multi.go
-* Congratulations!
+* Selamat!
-You finished this lesson!
+Anda telah menyelesaikan pelajaran ini!
-You can go back to the list of [[/list][modules]] to find what to learn next, or continue with the [[javascript:click('.next-page')][next lesson]].
+Anda bisa kembali ke daftar
+[[/list][modul]]
+untuk melihat apa yang bisa dipelajari selanjutnya, atau meneruskan ke
+[[javascript:click(".next-page")][pelajaran selanjutnya]].
diff --git a/content/flowcontrol/if-and-else.go b/content/flowcontrol/if-and-else.go
index 32f92a9..f627c40 100644
--- a/content/flowcontrol/if-and-else.go
+++ b/content/flowcontrol/if-and-else.go
@@ -13,7 +13,7 @@ func pow(x, n, lim float64) float64 {
} else {
fmt.Printf("%g >= %g\n", v, lim)
}
- // can't use v here, though
+ // v tidak dapat digunakan disini
return lim
}
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.article b/content/methods.article
index 34aa673..bdef0ac 100644
--- a/content/methods.article
+++ b/content/methods.article
@@ -1,309 +1,332 @@
-Methods and interfaces
-This lesson covers methods and interfaces, the constructs that define objects and their behavior.
+Method dan Interface
+Pelajaran ini membahas method dan interface, konstruksi yang membuat objek dan perilakunya.
-The Go Authors
+Para Penggubah Go
https://golang.org
-* Methods
+* Method
-Go does not have classes.
-However, you can define methods on types.
+Go tidak memiliki class.
+Namun, anda bisa mendefinisikan method pada tipe.
-A method is a function with a special _receiver_ argument.
+Sebuah method adalah sebuah fungsi dengan argumen khusus _receiver_.
-The receiver appears in its own argument list between the `func` keyword and
-the method name.
+_receiver_ muncul pada bagian antara kata kunci `func` and nama method.
-In this example, the `Abs` method has a receiver of type `Vertex` named `v`.
+Pada contoh berikut, method `Abs` memiliki _receiver_ dengan tipe `Vertex`
+bernama `v`.
.play methods/methods.go
-* Methods are functions
+* Method adalah fungsi
-Remember: a method is just a function with a receiver argument.
+Ingat: sebuah method hanyalah fungsi dengan argumen sebuah _receiver_.
-Here's `Abs` written as a regular function with no change in functionality.
+Berikut ini `Abs` ditulis sebagai fungsi biasa tanpa ada perubahan pada
+fungsionalitas.
.play methods/methods-funcs.go
-* Methods continued
+* Method lanjutan
-You can declare a method on non-struct types, too.
+Anda bisa mendeklarasikan method pada tipe selain `struct` juga.
-In this example we see a numeric type `MyFloat` with an `Abs` method.
+Pada contoh berikut kita dapat melihat sebuah tipe numerik `MyFloat` dengan
+method `Abs`.
-You can only declare a method with a receiver whose type is defined in the same
-package as the method.
-You cannot declare a method with a receiver whose type is defined in another
-package (which includes the built-in types such as `int`).
+Anda hanya bisa mendeklarasikan sebuah method dengan sebuah receiver yang
+tipenya didefinisikan di paket yang sama dengan method-nya.
+Anda tidak bisa mendeklarasikan sebuah method dengan receiver yang tipenya
+didefinisikan di paket yang lain (termasuk tipe dasar seperti `int`).
.play methods/methods-continued.go
-* Pointer receivers
+* Pointer-receiver
-You can declare methods with pointer receivers.
+Anda bisa mendeklarasikan method dengan _receiver_ berupa pointer.
-This means the receiver type has the literal syntax `*T` for some type `T`.
-(Also, `T` cannot itself be a pointer such as `*int`.)
+Hal ini berarti tipe _receiver_ memiliki sintaks `*T` untuk tipe `T`.
+(Dan juga, `T` itu sendiri tidak bisa berupa pointer ke tipe dasar seperti
+ `*int`.)
-For example, the `Scale` method here is defined on `*Vertex`.
+Sebagai contohnya, method `Scale` didefinisikan pada `*Vertex`.
-Methods with pointer receivers can modify the value to which the receiver
-points (as `Scale` does here).
-Since methods often need to modify their receiver, pointer receivers are more
-common than value receivers.
+Method dengan _pointer-receiver_ dapat mengubah nilai yang ditunjuk (seperti
+yang dilakukan oleh `Scale`).
+Karena method terkadang perlu mengubah _receiver_ nya, _pointer-receiver_
+lebih umum digunakan daripada _receiver_ dengan value.
-Try removing the `*` from the declaration of the `Scale` function on line 16
-and observe how the program's behavior changes.
+Coba hapus `*` dari deklarasi fungsi `Scale` pada baris 16 dan perhatikan
+bagaimana perilaku program berubah.
-With a value receiver, the `Scale` method operates on a copy of the original
-`Vertex` value.
-(This is the same behavior as for any other function argument.)
-The `Scale` method must have a pointer receiver to change the `Vertex` value
-declared in the `main` function.
+Dengan receiver-sebagai-value, method `Scale` beroperasi pada salinan dari
+nilai asli `Vertex`.
+(Perilaku ini juga berlaku pada argumen pada fungsi.)
+Method `Scale` harus memiliki sebuah pointer-receiver untuk dapat mengubah
+nilai `Vertex` yang dideklarasikan pada fungsi `main`.
.play methods/methods-pointers.go
-* Pointers and functions
+* Pointers dan fungsi
-Here we see the `Abs` and `Scale` methods rewritten as functions.
+Di sini kita lihat method `Abs` dan `Scale` dibuat ulang sebagai fungsi.
-Again, try removing the `*` from line 16.
-Can you see why the behavior changes?
-What else did you need to change for the example to compile?
+Sekali lagi, coba hilangkan `*` pada baris 16.
+Bisakah anda melihat perubahan perilakunya?
+Apa yang harus anda ubah selanjutnya supaya contoh tersebut dapat di
+kompilasi?
-(If you're not sure, continue to the next page.)
+(Jika anda tidak yakin, lanjutkan ke halaman berikutnya.)
.play methods/methods-pointers-explained.go
-* Methods and pointer indirection
+* Method dan pointer tidak langsung
-Comparing the previous two programs, you might notice that
-functions with a pointer argument must take a pointer:
+Bandingkan dua program sebelumnya, anda mungkin memperhatikan bahwa fungsi
+dengan sebuah argumen pointer harus menerima sebuah pointer:
- var v Vertex
+ var V Vertex
ScaleFunc(v, 5) // Compile error!
ScaleFunc(&v, 5) // OK
-while methods with pointer receivers take either a value or a pointer as the
-receiver when they are called:
+Sementara method dengan pointer-receiver dapat menerima sebuah nilai atau
+sebuah pointer sebagai receiver saat dipanggil:
var v Vertex
- v.Scale(5) // OK
+ v.Scale(5) // OK
p := &v
- p.Scale(10) // OK
+ p.Scale(10) // OK
-For the statement `v.Scale(5)`, even though `v` is a value and not a pointer,
-the method with the pointer receiver is called automatically.
-That is, as a convenience, Go interprets the statement `v.Scale(5)` as
-`(&v).Scale(5)` since the `Scale` method has a pointer receiver.
+Untuk perintah `v.Scale(5)`, walaupun `v` adalah sebuah nilai bukan sebuah
+pointer, method dengan pointer-receiver akan dipanggil secara otomatis.
+Maka, untuk mempermudah, Go menginterpretasikan perintah `v.Scale(5)` sebagai
+`(&v).Scale(5)` karena method Scale memiliki pointer-receiver.
.play methods/indirection.go
-* Methods and pointer indirection (2)
+* Method dan pointer tidak langsung (2)
-The equivalent thing happens in the reverse direction.
+Hal yang sama berlaku sebaliknya.
-Functions that take a value argument must take a value of that specific type:
+Fungsi yang menerima argumen nilai harus mendapatkan sebuah nilai dari tipe
+yang spesifik:
var v Vertex
fmt.Println(AbsFunc(v)) // OK
fmt.Println(AbsFunc(&v)) // Compile error!
-while methods with value receivers take either a value or a pointer as the
-receiver when they are called:
+Sementara method dengan value-receiver bisa menerima sebuah nilai atau sebuah
+pointer sebagai receiver saat dipanggil:
var v Vertex
fmt.Println(v.Abs()) // OK
p := &v
fmt.Println(p.Abs()) // OK
-In this case, the method call `p.Abs()` is interpreted as `(*p).Abs()`.
+Pada kasus ini, pemanggilan method `p.Abs()` diinterpretasikan sebagai
+`(*p).Abs()`.
.play methods/indirection-values.go
-* Choosing a value or pointer receiver
+* Memilih receiver sebagai nilai atau pointer
-There are two reasons to use a pointer receiver.
+Ada dua alasan kenapa menggunakan _pointer-receiver_.
-The first is so that the method can modify the value that its receiver points to.
+Pertama adalah supaya method dapat mengubah nilai yang ditunjuk oleh receiver.
-The second is to avoid copying the value on each method call.
-This can be more efficient if the receiver is a large struct, for example.
+Kedua adalah untuk menghindari menyalin nilai setiap kali method dipanggil.
+Hal ini bisa lebih efisien jika receiver adalah sebuah struct yang besar,
+sebagai contohnya.
-In this example, both `Scale` and `Abs` are with receiver type `*Vertex`,
-even though the `Abs` method needn't modify its receiver.
+Pada contoh ini, `Scale` dan `Abs` memiliki tipe receiver `*Vertex`, walaupun
+method `Abs` tidak perlu mengubah receiver-nya.
-In general, all methods on a given type should have either value or pointer
-receivers, but not a mixture of both.
-(We'll see why over the next few pages.)
+Secara umum, semua method dari sebuah tipe harus memiliki receiver sebagai
+nilai atau sebagai pointer, tapi tidak gabungan dari keduanya.
+(Kita akan lihat alasannya pada beberapa laman berikutnya.)
.play methods/methods-with-pointer-receivers.go
-* Interfaces
+* Interface
-An _interface_type_ is defined as a set of method signatures.
+Sebuah _type_interface_ didefinisikan sebagai sebuah kumpulan method penanda.
-A value of interface type can hold any value that implements those methods.
+Nilai dari tipe interface dapat menyimpan nilai apapun yang
+mengimplementasikan method tersebut.
-*Note:* There is an error in the example code on line 22.
-`Vertex` (the value type) doesn't implement `Abser` because
-the `Abs` method is defined only on `*Vertex` (the pointer type).
+*Catatan:* Terdapat kesalahan di contoh kode pada baris 22.
+`Vertex` (tipe nilai) tidak memenuhi `Abser` karena method `Abs` hanya
+didefinisikan pada `*Vertex` (tipe pointer).
.play methods/interfaces.go
-* Interfaces are implemented implicitly
+* Interface dipenuhi secara implisit
-A type implements an interface by implementing its methods.
-There is no explicit declaration of intent, no "implements" keyword.
+Sebuah tipe mengimplementasikan sebuah interface dengan mengimplementasikan
+method-methodnya.
+Tidak ada deklarasi eksplisit; tidak ada perintah "implements".
-Implicit interfaces decouple the definition of an interface from its
-implementation, which could then appear in any package without prearrangement.
+Interface implisit memisahkan definisi dari sebuah interface dari
+implementasinya, yang bisa saja muncul dalam paket manapun tanpa adanya
+penataan sebelumnya.
.play methods/interfaces-are-satisfied-implicitly.go
-* Interface values
+* Nilai interface
-Under the hood, interface values can be thought of as a tuple of a value and a
-concrete type:
+Isi interface dapat dibayangkan sebagai sebuah pasangan nilai dan sebuah tipe:
- (value, type)
+ (nilai, tipe)
-An interface value holds a value of a specific underlying concrete type.
+Sebuah interface mengandung sebuah nilai dari tipe tertentu.
-Calling a method on an interface value executes the method of the same name on
-its underlying type.
+Memanggil suatu method terhadap suatu interface akan mengeksekusi method
+dengan nama yang sama pada tipe yang dipegangnya.
.play methods/interface-values.go
-* Interface values with nil underlying values
+* Interface dengan nilai nil
-If the concrete value inside the interface itself is nil,
-the method will be called with a nil receiver.
+Jika nilai sebenarnya dari interface itu sendiri adalah nil, method akan
+dipanggil dengan receiver bernilai nil.
-In some languages this would trigger a null pointer exception,
-but in Go it is common to write methods that gracefully handle being called
-with a nil receiver (as with the method `M` in this example.)
+Pada beberapa bahasa pemrograman hal ini akan mengakibatkan
+`null`pointer`exception` atau kesalahan karena pointer bernilai kosong, tapi
+pada Go sangat umum menulis method dengan receiver bernilai nil (seperti
+method `M` pada contoh di sebelah.)
-Note that an interface value that holds a nil concrete value is itself non-nil.
+Ingatlah bahwa sebuah isi interface yang mengandung nilai konkrit nil
+sebenarnya adalah non-nil.
.play methods/interface-values-with-nil.go
-* Nil interface values
+* Isi interface dengan nil
-A nil interface value holds neither value nor concrete type.
+Sebuah isi interface yang nil tidak mengandung nilai dan tipe konkrit.
-Calling a method on a nil interface is a run-time error because there is no
-type inside the interface tuple to indicate which _concrete_ method to call.
+Memanggil sebuah method pada sebuah interface yang nil akan mengakibatkan
+kesalahan run-time karena tidak ada tipe di dalam interface yang
+mengindikasikan method _konkrit_ yang akan dipanggil.
.play methods/nil-interface-values.go
-* The empty interface
+* Interface kosong
-The interface type that specifies zero methods is known as the _empty_interface_:
+Tipe interface yang tidak memiliki method dikenal juga dengan interface
+kosong:
interface{}
-An empty interface may hold values of any type.
-(Every type implements at least zero methods.)
+Sebuah interface kosong bisa menyimpan nilai dari tipe apapun.
+(Setiap tipe mengimplementasikan paling tidak nol method.)
-Empty interfaces are used by code that handles values of unknown type.
-For example, `fmt.Print` takes any number of arguments of type `interface{}`.
+Interface kosong digunakan pada kode yang menangani nilai yang tidak
+diketahui.
+Sebagai contohnya, `fmt.Print` mengambil sejumlah argumen dengan tipe
+`interface{}`.
.play methods/empty-interface.go
-* Type assertions
+* Penegasan tipe
-A _type_assertion_ provides access to an interface value's underlying concrete value.
+Suatu _penegasan_tipe_ menyediakan akses ke isi interface di balik nilai
+konkritnya.
t := i.(T)
-This statement asserts that the interface value `i` holds the concrete type `T`
-and assigns the underlying `T` value to the variable `t`.
+Perintah di atas menegaskan bahwa isi interface `i` menyimpan tipe konkrit `T`
+dan memberikan nilai `T` ke variabel `t`.
-If `i` does not hold a `T`, the statement will trigger a panic.
+Jika `i` tidak mengandung tipe `T`, perintah tersebut akan memicu `panic`.
-To _test_ whether an interface value holds a specific type,
-a type assertion can return two values: the underlying value
-and a boolean value that reports whether the assertion succeeded.
+Untuk _memeriksa_ apakah sebuah isi interface benar mengandung tipe tertentu,
+penegasan tipe bisa mengembalikan dua nilai: nilai yang dikandung dan sebuah
+nilai boolean yang memberitahu apakah penegasan sukses atau tidak.
t, ok := i.(T)
-If `i` holds a `T`, then `t` will be the underlying value and `ok` will be true.
+Jika `i` mengandung `T`, maka `t` akan menyimpan nilai dan `ok` akan bernilai
+true.
-If not, `ok` will be false and `t` will be the zero value of type `T`,
-and no panic occurs.
+Jika tidak, `ok` akan bernilai false dan `t` akan bernilai kosong sesuai
+dengan tipe `T`, dan panic tidak akan terjadi.
-Note the similarity between this syntax and that of reading from a map.
+Ingatlah kesamaan antara sintaks ini dengan membaca dari sebuah map.
.play methods/type-assertions.go
-* Type switches
+* Penggunaan switch untuk tipe
-A _type_switch_ is a construct that permits several type assertions in series.
+Sebuah _tipe_switch_ adalah bentukan yang membolehkan beberapa penegasan tipe
+secara serial.
-A type switch is like a regular switch statement, but the cases in a type
-switch specify types (not values), and those values are compared against
-the type of the value held by the given interface value.
+Tipe switch sama seperti perintah switch biasa, tapi dengan nilai case mengacu
+pada tipe (bukan nilai), dan nilai case tersebut dibandingkan dengan tipe yang
+dikandung oleh isi interface yang diberikan.
switch v := i.(type) {
case T:
- // here v has type T
+ // di sini v bertipe T
case S:
- // here v has type S
+ // di sini v bertipe S
default:
- // no match; here v has the same type as i
+ // tidak ada yang cocok; disini v bertipe sama dengan i
}
-The declaration in a type switch has the same syntax as a type assertion `i.(T)`,
-but the specific type `T` is replaced with the keyword `type`.
+Deklarasi dalam sebuah tipe switch memiliki sintaks yang sama dengan penegasan
+tipe `i.(T)`, tapi dengan `T` diganti dengan kata `type`.
-This switch statement tests whether the interface value `i`
-holds a value of type `T` or `S`.
-In each of the `T` and `S` cases, the variable `v` will be of type
-`T` or `S` respectively and hold the value held by `i`.
-In the default case (where there is no match), the variable `v` is
-of the same interface type and value as `i`.
+Perintah switch berikut menguji apakah isi interface `i` mengandung sebuah
+nilai dari tipe `T` atau `S`.
+Pada setiap `case` dari `T` dan `S`, variabel `v` akan memiliki tipe `T` atau
+`S` dan memiliki nilai yang dikandung oleh `i`.
+Pada `default case` (yang mana tidak ada tipe yang sama ditemukan), variabel
+`v` akan memiliki tipe dan nilai yang sama dengan `i`.
.play methods/type-switches.go
-* Stringers
+* Stringer
-One of the most ubiquitous interfaces is [[//golang.org/pkg/fmt/#Stringer][`Stringer`]] defined by the [[//golang.org/pkg/fmt/][`fmt`]] package.
+Interface yang ada dimanapun yaitu
+[[//golang.org/pkg/fmt/#Stringer][`Stringer`]]
+didefinisikan oleh paket
+[[//golang.org/pkg/fmt/][`fmt`]].
type Stringer interface {
String() string
}
-A `Stringer` is a type that can describe itself as a string. The `fmt` package
-(and many others) look for this interface to print values.
+Sebuah `Stringer` adalah suatu tipe yang mendeskripsikan dirinya sendiri
+sebagai string.
+Paket `fmt` (dan banyak lainnya) menggunakan interface ini untuk mencetak
+nilai.
.play methods/stringer.go
-* Exercise: Stringers
+* Latihan: Stringer
-Make the `IPAddr` type implement `fmt.Stringer` to print the address as
-a dotted quad.
+Buat tipe `IPAddr` yang mengimplementasikan `fmt.Stringer` untuk mencetak
+alamat dengan empat tanda titik.
-For instance, `IPAddr{1,`2,`3,`4}` should print as `"1.2.3.4"`.
+Misalnya, `IPAddr{1,`2,`3,`4}` mengeluarkan `"1.2.3.4"`.
.play methods/exercise-stringer.go
-* Errors
+* Error
-Go programs express error state with `error` values.
+Program Go mengekspresikan keadaan error dengan nilai `error`.
-The `error` type is a built-in interface similar to `fmt.Stringer`:
+Tipe `error` adalah interface buatan mirip dengan `fmt.Stringer`:
type error interface {
Error() string
}
-(As with `fmt.Stringer`, the `fmt` package looks for the `error` interface when
-printing values.)
+Seperti dengan `fmt.Stringer`, paket `fmt` mencari interface `error` saat
+mencetak nilai.
-Functions often return an `error` value, and calling code should handle errors
-by testing whether the error equals `nil`.
+Fungsi terkadang mengembalikan nilai `error`, dan kode yang memanggilnya harus
+menangani error dengan memeriksa apakah error bernilai `nil`.
i, err := strconv.Atoi("42")
if err != nil {
@@ -312,76 +335,99 @@ by testing whether the error equals `nil`.
}
fmt.Println("Converted integer:", i)
-A nil `error` denotes success; a non-nil `error` denotes failure.
+`error` yang nil menandakan sukses; `error` yang bukan-nil menandakan adanya
+kesalahan.
.play methods/errors.go
-* Exercise: Errors
+* Latihan: Error
-Copy your `Sqrt` function from the [[/flowcontrol/8][earlier exercise]] and modify it to return an `error` value.
+Salin fungsi `Sqrt` anda dari
+[[/flowcontrol/8][latihan sebelumnya]]
+dan ubah untuk mengembalikan nilai `error`.
-`Sqrt` should return a non-nil error value when given a negative number, as it doesn't support complex numbers.
+`Sqrt` seharusnya mengembalikan nilai error bukan-nil saat diberikan angka
+negatif, karena tidak mendukung bilangan kompleks.
-Create a new type
+Buatlah tipe baru
type ErrNegativeSqrt float64
-and make it an `error` by giving it a
+dan buat dia sebagai `error` dengan memberikan method
func (e ErrNegativeSqrt) Error() string
-method such that `ErrNegativeSqrt(-2).Error()` returns `"cannot`Sqrt`negative`number:`-2"`.
+sehingga `ErrNegativeSqrt(-2).Error()` mengembalikan
+`"cannot`Sqrt`negative`number:`-2"`.
-*Note:* A call to `fmt.Sprint(e)` inside the `Error` method will send the program into an infinite loop. You can avoid this by converting `e` first: `fmt.Sprint(float64(e))`. Why?
+*Catatan:* Pemanggilan `fmt.Sprint(e)` di dalam method `Error` akan membuat
+program berulang tak henti.
+Anda dapat menghindari hal tersebut dengan mengkonversi `e`:
+`fmt.Sprint(float64(e))`. _Kenapa?_
-Change your `Sqrt` function to return an `ErrNegativeSqrt` value when given a negative number.
+Ubah fungsi `Sqrt` mengembalikan nilai `ErrNegativeSqrt` saat diberikan nilai
+negatif.
.play methods/exercise-errors.go
-* Readers
+* Reader
-The `io` package specifies the `io.Reader` interface,
-which represents the read end of a stream of data.
+Paket `io` memiliki spesifikasi interface `io.Reader`, yang merepresentasikan
+berakhirnya pembacaan sebuah aliran data.
-The Go standard library contains [[https://golang.org/search?q=Read#Global][many implementations]] of this interface, including files, network connections, compressors, ciphers, and others.
+Standar pustaka Go memiliki
+[[https://golang.org/search?q=Read#Global][banyak implementasi]]
+dari interface tersebut, termasuk berkas, koneksi jaringan, kompresi,
+_cipher_, dll.
-The `io.Reader` interface has a `Read` method:
+Interface `io.Reader` memiliki method `Read`:
func (T) Read(b []byte) (n int, err error)
-`Read` populates the given byte slice with data and returns the number of bytes
-populated and an error value. It returns an `io.EOF` error when the stream
-ends.
+`Read` mengisi parameter slice byte dengan data dan mengembalikan jumlah
+byte yang diisi dan nilai errornya jika ada.
+Ia mengembalikan error `io.EOF` saat aliran data berakhir.
-The example code creates a
+Contoh kode membuat sebuah
[[//golang.org/pkg/strings/#Reader][`strings.Reader`]]
-and consumes its output 8 bytes at a time.
+dan memproses 8 bytes keluarannya.
.play methods/reader.go
-* Exercise: Readers
+* Latihan: Reader
-Implement a `Reader` type that emits an infinite stream of the ASCII character
-`'A'`.
+Implementasikan sebuah tipe `Reader` yang menghilangkan karakter ASCII `'A'`
+yang panjang.
.play methods/exercise-reader.go
-* Exercise: rot13Reader
+* Latihan: rot13Reader
-A common pattern is an [[https://golang.org/pkg/io/#Reader][io.Reader]] that wraps another `io.Reader`, modifying the stream in some way.
+Pola umumnya adalah sebuah
+[[https://golang.org/pkg/io/#Reader][io.Reader]]
+yang membungkus `io.Reader` lainnya, memodifikasi aliran data dengan cara
+tertentu.
-For example, the [[https://golang.org/pkg/compress/gzip/#NewReader][gzip.NewReader]] function takes an `io.Reader` (a stream of compressed data) and returns a `*gzip.Reader` that also implements `io.Reader` (a stream of the decompressed data).
+Sebagai contohnya, fungsi
+[[https://golang.org/pkg/compress/gzip/#NewReader][gzip.NewReader]]
+mengambil `io.Reader` (aliran data terkompres) dan mengembalikan
+`*gzip.Reader` yang juga mengimplementasikan `io.Reader` (aliran data
+tak-terkompres).
-Implement a `rot13Reader` that implements `io.Reader` and reads from an `io.Reader`, modifying the stream by applying the [[https://en.wikipedia.org/wiki/ROT13][rot13]] substitution cipher to all alphabetical characters.
+Implementasikan `rot13Reader` yang mengimplementasikan `io.Reader` dengan
+membaca dari `io.Reader`, modifikasi aliran data dengan menerapkan penyandian
+[[https://en.wikipedia.org/wiki/ROT13][rot13]]
+terhadap semua karakter alfabet.
-The `rot13Reader` type is provided for you.
-Make it an `io.Reader` by implementing its `Read` method.
+Tipe `rot13Reader` telah disediakan untuk anda.
+Buatlah ia menjadi `io.Reader` dengan mengimplementasikan method `Read`.
.play methods/exercise-rot-reader.go
-* Images
+* Gambar
-[[https://golang.org/pkg/image/#Image][Package image]] defines the `Image` interface:
+[[https://golang.org/pkg/image/#Image][Paket image]]
+mendefinisikan interface `Image`:
package image
@@ -391,32 +437,49 @@ Make it an `io.Reader` by implementing its `Read` method.
At(x, y int) color.Color
}
-*Note*: the `Rectangle` return value of the `Bounds` method is actually an
-[[https://golang.org/pkg/image/#Rectangle][`image.Rectangle`]], as the
-declaration is inside package `image`.
+*Catatan*: Nilai kembalian `Rectangle` dari method `Bounds` sebenarnya adalah
+deklarasi
+[[https://golang.org/pkg/image/#Rectangle][`image.Rectangle`]]
+yang telah ada di dalam paket `image`.
-(See [[https://golang.org/pkg/image/#Image][the documentation]] for all the details.)
+(Lihat
+[[https://golang.org/pkg/image/#Image][dokumentasi untuk paket Image]]
+untuk lebih jelasnya.)
-The `color.Color` and `color.Model` types are also interfaces, but we'll ignore that by using the predefined implementations `color.RGBA` and `color.RGBAModel`. These interfaces and types are specified by the [[https://golang.org/pkg/image/color/][image/color package]]
+Tipe `color.Color` dan `color.Model` juga interface, tapi kita akan
+menggunakan implementasi `color.RGBA` dan `color.RGBAModel`.
+Interface dan tipe tersebut dispesifikasikan oleh
+[[https://golang.org/pkg/image/color/][paket image/color]].
.play methods/images.go
-* Exercise: Images
+* Latihan: Gambar
-Remember the [[/moretypes/18][picture generator]] you wrote earlier? Let's write another one, but this time it will return an implementation of `image.Image` instead of a slice of data.
+Masih ingat dengan [[/moretypes/18][generator gambar]] yang anda buat
+sebelumnya?
+Mari kita buat satu lagi, tapi kali ini mengembalikan implementasi dari
+`image.Image` bukan sebuah slice dari data.
-Define your own `Image` type, implement [[https://golang.org/pkg/image/#Image][the necessary methods]], and call `pic.ShowImage`.
+Definisikan tipe `Image` anda sendiri, kemudian implementasikan
+[[https://golang.org/pkg/image/#Image][method-method yang dibutuhkan]]
+, dan panggil `pic.ShowImage`.
-`Bounds` should return a `image.Rectangle`, like `image.Rect(0,`0,`w,`h)`.
+`Bounds` seharusnya mengembalikan `image.Rectangle`, seperti
+`image.Rect(0,`0,`w,`h)`.
-`ColorModel` should return `color.RGBAModel`.
+`ColorModel` seharusnya mengembalikan `color.RGBAModel`.
-`At` should return a color; the value `v` in the last picture generator corresponds to `color.RGBA{v,`v,`255,`255}` in this one.
+`At` seharusnya mengembalikan sebuah warna;
+nilai `v` pada generator gambar berkoresponden dengan
+`color.RGBA{v,`v,`255,`255}`.
.play methods/exercise-images.go
-* Congratulations!
+* Selamat!
-You finished this lesson!
+Anda telah menyelesaikan pelajaran ini!
-You can go back to the list of [[/list][modules]] to find what to learn next, or continue with the [[javascript:click('.next-page')][next lesson]].
+Anda bisa kembali ke daftar
+[[/list][modul]]
+untuk melihat apa yang bisa dipelajari selanjutnya, atau meneruskan ke
+[[javascript:click(".next-page")][pelajaran selanjutnya]].
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/exercise-images.go b/content/methods/exercise-images.go
index 5b93246..34bd129 100644
--- a/content/methods/exercise-images.go
+++ b/content/methods/exercise-images.go
@@ -2,7 +2,7 @@
package main
-import "golang.org/x/tour/pic"
+import "github.com/golang-id/tour/pic"
type Image struct{}
diff --git a/content/methods/exercise-reader.go b/content/methods/exercise-reader.go
index e1394b2..7f1dfdd 100644
--- a/content/methods/exercise-reader.go
+++ b/content/methods/exercise-reader.go
@@ -2,7 +2,7 @@
package main
-import "golang.org/x/tour/reader"
+import "github.com/golang-id/tour/reader"
type MyReader struct{}
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..3424b79 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 kenal dengan tipe %T!\n", v)
}
}
diff --git a/content/moretypes.article b/content/moretypes.article
index 5fe9401..ff45dfb 100644
--- a/content/moretypes.article
+++ b/content/moretypes.article
@@ -1,150 +1,158 @@
-More types: structs, slices, and maps.
-Learn how to define types based on existing ones: this lesson covers structs, arrays, slices, and maps.
+Tipe lanjut: struct, slice, dan map.
+Belajar cara mendefinisikan tipe: pelajaran ini membahas struct, array, slice, dan map.
-The Go Authors
+Para Penggubah Go
https://golang.org
-* Pointers
+* Pointer
-Go has pointers.
-A pointer holds the memory address of a value.
+Go memiliki pointer.
+Sebuah pointer menyimpan alamat dari sebuah nilai.
-The type `*T` is a pointer to a `T` value. Its zero value is `nil`.
+Tipe `*T` adalah pointer ke sebuah nilai `T`.
+Nilai kosong dari pointer adalah `nil`.
var p *int
-The `&` operator generates a pointer to its operand.
+Operator `&` mengembalikan operan pointer dari variabel.
i := 42
p = &i
-The `*` operator denotes the pointer's underlying value.
+Operator `*` mengembalikan nilai yang ditunjuk oleh pointer.
- fmt.Println(*p) // read i through the pointer p
- *p = 21 // set i through the pointer p
+ fmt.Println(*p) // baca nilai i lewat pointer p
+ *p = 21 // set nilai i lewat pointer p
-This is known as "dereferencing" or "indirecting".
+Cara ini disebut dengan "dereferencing" atau "indirecting".
-Unlike C, Go has no pointer arithmetic.
+Tidak seperti C, Go tidak memiliki fungsi aritmatika pada pointer.
.play moretypes/pointers.go
-* Structs
+* Tipe data abstrak "struct"
-A `struct` is a collection of fields.
+Sebuah `struct` adalah kumpulan dari berbagai variabel.
.play moretypes/structs.go
-* Struct Fields
+* Bagian dari struct
-Struct fields are accessed using a dot.
+Bagian dari struct diakses menggunakan sebuah titik.
.play moretypes/struct-fields.go
-* Pointers to structs
+* Pointer ke struct
-Struct fields can be accessed through a struct pointer.
+Bagian dari struct dapat diakses lewat pointer ke struct.
-To access the field `X` of a struct when we have the struct pointer `p` we could
-write `(*p).X`.
-However, that notation is cumbersome, so the language permits us instead to
-write just `p.X`, without the explicit dereference.
+Untuk mengakses bagian `X` dari sebuah struct bila kita memiliki pointer ke
+struct `p`, kita dapat menulisnya dengan `(*p).X`.
+Namun, notasi tersebut tidak praktis, sehingga Go membolehkan kita
+mengaksesnya langsung dengan menulis hanya `p.X`.
.play moretypes/struct-pointers.go
-* Struct Literals
+* Inisialisasi struct
-A struct literal denotes a newly allocated struct value by listing the values of its fields.
+Sebuah `struct` bisa dibuat dengan mengisinya dengan nilai bagian-bagiannya.
-You can list just a subset of fields by using the `Name:` syntax. (And the order of named fields is irrelevant.)
+Anda juga bisa mengisi hanya sebagian dari kolom dengan menggunakan sintaks
+`Name:` (urutan dari bagian-bagiannya tidak berpengaruh).
-The special prefix `&` returns a pointer to the struct value.
+Prefik `&` mengembalikan sebuah pointer ke `struct`.
.play moretypes/struct-literals.go
-* Arrays
+* Array
-The type `[n]T` is an array of `n` values of type `T`.
+Deklarasi tipe dengan `[n]T` adalah untuk array dengan jumlah `n` dan bertipe
+`T`.
-The expression
+Ekspresi
var a [10]int
-declares a variable `a` as an array of ten integers.
+mendeklarasikan sebuah variabel `a` sebagai sebuah array dari sepuluh integer.
-An array's length is part of its type, so arrays cannot be resized.
-This seems limiting, but don't worry;
-Go provides a convenient way of working with arrays.
+Panjang sebuah array adalah bagian dari tipenya, jadi array tidak bisa diubah
+ukurannya.
+Hal ini sepertinya membatasi, tapi jangan khawatir;
+Go menyediakan cara yang mudah untuk bekerja dengan array.
.play moretypes/array.go
-* Slices
+* Potongan ("slice")
-An array has a fixed size.
-A slice, on the other hand, is a dynamically-sized,
-flexible view into the elements of an array.
-In practice, slices are much more common than arrays.
+Sebuah array memiliki ukuran yang tetap.
+Sebuah slice ukurannya bisa dinamis, bisa mengacu secara fleksibel ke elemen
+dalam sebuah array.
+Dalam praktiknya, slice lebih sering digunakan daripada array.
-The type `[]T` is a slice with elements of type `T`.
+Tipe `[]T` adalah sebuah slice dengan elemen bertipe `T`.
-A slice is formed by specifying two indices, a low and
-high bound, separated by a colon:
+Sebuah slice dibentuk dengan menspesifikasikan dua indeks, batas bawah dan
+batas atas, dipisahkan oleh sebuah tanda titik-dua:
- a[low : high]
+ a[bawah : atas]
-This selects a half-open range which includes the first
-element, but excludes the last one.
+Notasi di atas memotong rentang dari slice `a` yang mengikutkan elemen
+`bawah`, tapi tidak memasukan bagian terakhir (atas).
-The following expression creates a slice which includes
-elements 1 through 3 of `a`:
+Ekspresi berikut membuat sebuah slice yang mengikutkan elemen 1 sampai 3 dari
+slice `a`:
a[1:4]
.play moretypes/slices.go
-* Slices are like references to arrays
+* Slice adalah referensi ke array
-A slice does not store any data,
-it just describes a section of an underlying array.
+Sebuah slice tidak menyimpan data, ia hanya mendeskripsikan sebuah bagian dari
+array.
-Changing the elements of a slice modifies the
-corresponding elements of its underlying array.
+Mengubah nilai dari elemen dari sebuah slice juga mengubah elemen di
+array-nya.
-Other slices that share the same underlying array will see those changes.
+Slice lain yang berbagi elemen array yang sama akan mendapatkan perubahan yang
+sama.
.play moretypes/slices-pointers.go
-* Slice literals
+* Inisialisasi Slice
-A slice literal is like an array literal without the length.
+Menginisialisasi slice mirip dengan array tapi tanpa mendefinisikan
+panjangnya.
-This is an array literal:
+Berikut ini adalah sebuah array:
[3]bool{true, true, false}
-And this creates the same array as above,
-then builds a slice that references it:
+Dan berikut ini membuat array yang sama seperti di atas, kemudian membuat
+sebuah slice yang mengacu kepadanya:
[]bool{true, true, false}
.play moretypes/slice-literals.go
-* Slice defaults
+* Nilai Default Slice
-When slicing, you may omit the high or low bounds to use their defaults instead.
+Saat memotong, anda bisa mengindahkan batas bawah atau atas sehingga Go akan
+menggunakan nilai _default_-nya.
-The default is zero for the low bound and the length of the slice for the high bound.
+Nilai _default_-nya adalah nol untuk batas bawah dan panjang dari slice untuk
+batas atas.
-For the array
+Untuk sebuah array berikut,
var a [10]int
-these slice expressions are equivalent:
+ekspresi slice berikut adalah setara:
a[0:10]
a[:10]
@@ -154,47 +162,47 @@ these slice expressions are equivalent:
.play moretypes/slice-bounds.go
-* Slice length and capacity
+* Panjang dan Kapasitas Slice
-A slice has both a _length_ and a _capacity_.
+Sebuah slice memiliki _panjang_ dan _kapasitas_.
-The length of a slice is the number of elements it contains.
+Panjang dari sebuah slice yaitu jumlah dari elemen yang dimilikinya.
-The capacity of a slice is the number of elements in the underlying array,
-counting from the first element in the slice.
+Kapasitas dari sebuah slice adalah jumlah dari elemen array yang dikandungnya,
+dihitung dari elemen pertama di dalam slice.
-The length and capacity of a slice `s` can be obtained using the expressions
-`len(s)` and `cap(s)`.
+Panjang dan kapasitas dari sebuah slice `s` dapat diambil dengan menggunakan
+ekspresi `len(s)` dan `cap(s)`.
-You can extend a slice's length by re-slicing it,
-provided it has sufficient capacity.
-Try changing one of the slice operations in the example program to extend it
-beyond its capacity and see what happens.
+Anda bisa memperluas panjang dari sebuah slice dengan me-motong-ulang, bila
+kapasitasnya cukup.
+Coba ubah salah satu operasi slice di contoh program sebelah untuk
+memperluasnya melebihi kapasitasnya dan lihat apa yang terjadi.
.play moretypes/slice-len-cap.go
-* Nil slices
+* Slice kosong
-The zero value of a slice is `nil`.
+Nilai kosong dari slice adalah `nil`.
-A nil slice has a length and capacity of 0
-and has no underlying array.
+Slice yang kosong memiliki panjang dan kapasitas 0, dan tidak memiliki array
+di dalamnya.
.play moretypes/nil-slices.go
-* Creating a slice with make
+* Membuat slice dengan `make`
-Slices can be created with the built-in `make` function;
-this is how you create dynamically-sized arrays.
+Slice dapat dibuat dengan fungsi `make`;
+dengan fungsi tersebut anda bisa membuat array dengan ukuran yang dinamis.
-The `make` function allocates a zeroed array
-and returns a slice that refers to that array:
+Fungsi `make` mengalokasikan array yang dikosongkan dan mengembalikan sebuah
+slice yang mengacu pada array tersebut.
a := make([]int, 5) // len(a)=5
-To specify a capacity, pass a third argument to `make`:
+Untuk menentukan kapasitasnya, tambahkan argumen ketiga pada `make`:
b := make([]int, 0, 5) // len(b)=0, cap(b)=5
@@ -204,158 +212,191 @@ To specify a capacity, pass a third argument to `make`:
.play moretypes/making-slices.go
-* Slices of slices
+* Slice dari slice
-Slices can contain any type, including other slices.
+Slice bisa mengandung tipe apapun, termasuk slice lainnya.
.play moretypes/slices-of-slice.go
-* Appending to a slice
+* Menambahkan elemen ke slice
-It is common to append new elements to a slice, and so Go provides a built-in
-`append` function. The [[https://golang.org/pkg/builtin/#append][documentation]]
-of the built-in package describes `append`.
+Sangat umum untuk menambahkan elemen ke slice, sehingga Go menyediakan fungsi
+`append`.
+[[https://golang.org/pkg/builtin/#append][Dokumentasinya]]
+menjelaskan lebih lanjut dari fungsi `append`.
func append(s []T, vs ...T) []T
-The first parameter `s` of `append` is a slice of type `T`, and the rest are
-`T` values to append to the slice.
+Parameter pertama `s` dari `append` adalah sebuah slice dengan tipe `T`, dan
+sisanya adalah nilai `T` yang akan ditambahkan ke slice.
-The resulting value of `append` is a slice containing all the elements of the
-original slice plus the provided values.
+Hasil dari `append` yaitu sebuah slice yang berisi semua elemen dari slice
+awal berikut dengan nilai yang ditambahkan.
-If the backing array of `s` is too small to fit all the given values a bigger
-array will be allocated. The returned slice will point to the newly allocated
-array.
+Jika array awal `s` terlalu kecil untuk nilai yang ditambahkan, maka array
+yang lebih besar akan dialokasikan.
+Kembaliannya yaitu slice yang merujuk ke array yang baru dialokasikan.
-(To learn more about slices, read the [[https://blog.golang.org/go-slices-usage-and-internals][Slices: usage and internals]] article.)
+(Untuk belajar lebih lanjut tentang slice, bacalah artikel
+[[https://blog.golang.org/go-slices-usage-and-internals][Slices: usage and internals]].)
.play moretypes/append.go
-* Range
+* Perintah "range"
-The `range` form of the `for` loop iterates over a slice or map.
+Perintah `range` pada pengulangan `for` mengiterasi sebuah slice atau map.
-When ranging over a slice, two values are returned for each iteration.
-The first is the index, and the second is a copy of the element at that index.
+Saat melakukan pengulangan dengan `range` pada slice, dua nilai akan
+dikembalikan pada setiap iterasi.
+Nilai pertama yaitu indeks, dan nilai kedua yaitu _salinan_ dari elemen pada
+indeks tersebut.
.play moretypes/range.go
-* Range continued
-You can skip the index or value by assigning to `_`.
+* Perintah "range" lanjutan
+
+Anda bisa melewati indeks atau nilai dengan operator `_`.
for i, _ := range pow
for _, value := range pow
-If you only want the index, you can omit the second variable.
+Jika anda hanya menginginkan indeks saja, variabel kedua bisa dihilangkan.
for i := range pow
.play moretypes/range-continued.go
-* Exercise: Slices
+* Latihan: Slice
-Implement `Pic`. It should return a slice of length `dy`, each element of which is a slice of `dx` 8-bit unsigned integers. When you run the program, it will display your picture, interpreting the integers as grayscale (well, bluescale) values.
+Implementasikan `Pic`.
+Fungsi tersebut harus mengembalikan sebuah slice dengan panjang `dy`, setiap
+elemennya merupakan sebuah slice `dx` 8-bit unsigned integer.
+Saat anda menjalankan program, ia akan menampilkan gambar anda,
+mengiterpretasikan nilai integer dengan warna abu-abu.
-The choice of image is up to you. Interesting functions include `(x+y)/2`, `x*y`, and `x^y`.
+Pilihan gambarnya terserah anda.
+Fungsi menarik yang bisa diikutkan berupa `(x+y)/2`, `x*y`, dan `x^y`.
-(You need to use a loop to allocate each `[]uint8` inside the `[][]uint8`.)
+(Anda membutuhkan pengulangan untuk mengalokasikan setiap `[]uint8`
+ke dalam `[][]uint8`.)
-(Use `uint8(intValue)` to convert between types.)
+(Gunakan `uint8(intValue)` untuk mengkonversi antara tipe.)
.play moretypes/exercise-slices.go
-* Maps
-A map maps keys to values.
+* Map
+
+Sebuah map memetakan sebuah kunci (_key_) dengan nilainya.
-The zero value of a map is `nil`.
-A `nil` map has no keys, nor can keys be added.
+Nilai kosong dari sebuah map adalah `nil`.
+Sebuah map yang `nil` tidak memiliki kunci, tidak juga dapat ditambahkan kunci
+baru.
-The `make` function returns a map of the given type,
-initialized and ready for use.
+Fungsi `make` mengembalikan sebuah map dengan tipenya, diinisialisasi dan siap
+untuk digunakan.
.play moretypes/maps.go
-* Map literals
+* Inisialisasi Map
-Map literals are like struct literals, but the keys are required.
+map diinisialisasi seperti pada `struct`, tapi dengan membubuhkan _key_-nya.
.play moretypes/map-literals.go
-* Map literals continued
+* Inisialisasi map lanjutan
-If the top-level type is just a type name, you can omit it from the elements of the literal.
+Jika level teratas dari tipe hanya nama tipe, anda bisa menghilangkannya dari inisialisasi elemen map.
.play moretypes/map-literals-continued.go
-* Mutating Maps
+* Operasi map
-Insert or update an element in map `m`:
+Mengisi atau mengubah elemen dalam map `m`:
m[key] = elem
-Retrieve an element:
+Mengambil elemen:
elem = m[key]
-Delete an element:
+Menghapus elemen:
delete(m, key)
-Test that a key is present with a two-value assignment:
+Menguji apakah sebuah _key_ ada dalam map:
elem, ok = m[key]
-If `key` is in `m`, `ok` is `true`. If not, `ok` is `false`.
+Jika `key` ada dalam `m`, `ok` bernilai `true`.
+Jika tidak ada, `ok` bernilai `false`.
-If `key` is not in the map, then `elem` is the zero value for the map's element type.
+Jika `key` tidak ada dalam map, maka `elem` berisi nilai kosong sesuai dengan
+tipe elemen.
-*Note:* If `elem` or `ok` have not yet been declared you could use a short declaration form:
+*Catatan:* Jika `elem` atau `ok` belum dideklarasikan anda bisa menggunakan
+bentuk deklarasi singkat berikut:
elem, ok := m[key]
.play moretypes/mutating-maps.go
-* Exercise: Maps
+* Latihan: map
-Implement `WordCount`. It should return a map of the counts of each “word” in the string `s`. The `wc.Test` function runs a test suite against the provided function and prints success or failure.
+Implementasikan `WordCount`.
+Fungsi tersebut mengembalikan sebuah map dari penghitungan setiap "kata" di
+dalam string `s`.
+Fungsi `wc.Test` menjalankan pengujian terhadap fungsi yang diberikan dan
+mencetak sukses atau salah.
-You might find [[https://golang.org/pkg/strings/#Fields][strings.Fields]] helpful.
+Anda mungkin menemukan artikel
+[[https://golang.org/pkg/strings/#Fields][strings.Fields]]
+membantu anda.
.play moretypes/exercise-maps.go
-* Function values
+* Nilai Fungsi
-Functions are values too. They can be passed around just like other values.
+Fungsi adalah suatu nilai juga.
+Fungsi dapat dikirimkan kemanapun seperti nilai lainnya.
-Function values may be used as function arguments and return values.
+Nilai fungsi bisa digunakan sebagai argumen pada fungsi lainnya dan sebagai
+nilai kembalian.
.play moretypes/function-values.go
-* Function closures
+* Fungsi closure
-Go functions may be closures. A closure is a function value that references variables from outside its body. The function may access and assign to the referenced variables; in this sense the function is "bound" to the variables.
+Fungsi pada Go bisa _closure_.
+_Closure_ adalah sebuah nilai fungsi yang merujuk variabel dari blok
+fungsinya.
+Fungsi closure bisa mengakses dan mengisi variabel yang dirujuk;
+dalam artian fungsi tersebut "terikat" ke variabel.
-For example, the `adder` function returns a closure. Each closure is bound to its own `sum` variable.
+Sebagai contohnya, fungsi `adder` mengembalikan sebuah closure.
+Setiap closure terikat dengan variabel `sum` -nya sendiri.
.play moretypes/function-closures.go
-* Exercise: Fibonacci closure
+* Latihan: Fibonacci dengan closure
-Let's have some fun with functions.
+Mari bermain dengan fungsi.
-Implement a `fibonacci` function that returns a function (a closure) that
-returns successive [[https://en.wikipedia.org/wiki/Fibonacci_number][fibonacci numbers]]
+Implementasikan sebuah fungsi `fibonacci` yang mengembalikan sebuah fungsi
+(closure) yang mengembalikan
+[[https://id.wikipedia.org/wiki/Bilangan_Fibonacci][bilangan fibonacci]]
(0, 1, 1, 2, 3, 5, ...).
.play moretypes/exercise-fibonacci-closure.go
-* Congratulations!
+* Selamat!
-You finished this lesson!
+Anda telah menyelesaikan pelajaran ini!
-You can go back to the list of [[/list][modules]] to find what to learn next, or continue with the [[javascript:click('.next-page')][next lesson]].
+Anda bisa kembali ke daftar
+[[/list][modul]]
+untuk melihat apa yang bisa dipelajari selanjutnya, atau meneruskan dengan
+[[javascript:click(".next-page")][pelajaran selanjutnya]].
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 d5a4e00..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 is a function that returns
-// a function that returns an int.
+// fibonacci adalah sebuah fungsi yang mengembalikan sebuah fungsi yang
+// mengembalikan sebuah integer.
func fibonacci() func() int {
}
diff --git a/content/moretypes/exercise-maps.go b/content/moretypes/exercise-maps.go
index e48e48a..71143b8 100644
--- a/content/moretypes/exercise-maps.go
+++ b/content/moretypes/exercise-maps.go
@@ -3,7 +3,7 @@
package main
import (
- "golang.org/x/tour/wc"
+ "github.com/golang-id/tour/wc"
)
func WordCount(s string) map[string]int {
diff --git a/content/moretypes/exercise-slices.go b/content/moretypes/exercise-slices.go
index 094ec09..ee766ef 100644
--- a/content/moretypes/exercise-slices.go
+++ b/content/moretypes/exercise-slices.go
@@ -2,7 +2,7 @@
package main
-import "golang.org/x/tour/pic"
+import "github.com/golang-id/tour/pic"
func Pic(dx, dy int) [][]uint8 {
}
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..eb1a442 100644
--- a/content/moretypes/slices-of-slice.go
+++ b/content/moretypes/slices-of-slice.go
@@ -8,14 +8,14 @@ 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"
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.article b/content/welcome.article
index e96256a..4646ead 100644
--- a/content/welcome.article
+++ b/content/welcome.article
@@ -1,56 +1,68 @@
-Welcome!
-Learn how to use this tour: including how to navigate the different lessons and how to run code.
+Selamat datang!
+Belajar cara menggunakan tur ini: termasuk cara navigasi pelajaran dan cara menjalankan kode.
-The Go Authors
+Para Penggubah Go
https://golang.org
-* Hello, 世界
+* Halo, 世界
-Welcome to a tour of the [[https://golang.org/][Go programming language]].
+Selamat datang di tur
+[[https://golang.org/][bahasa pemrograman Go]].
-The tour is divided into a list of modules that you can
-access by clicking on
-[[javascript:highlight(".logo")][A Tour of Go]] on the top left of the page.
+Tur ini dibagi menjadi beberapa modul yang dapat anda akses dengan mengklik
+pada [[javascript:highlight(".logo")][Tur Go]] di bagian kiri atas halaman.
-You can also view the table of contents at any time by clicking on the [[javascript:highlightAndClick(".nav")][menu]] on the top right of the page.
+Anda juga dapat setiap saat melihat daftar isi dengan mengklik pada
+[[javascript:highlightAndClick(".nav")][menu]]
+di kanan atas halaman.
-Throughout the tour you will find a series of slides and exercises for you
-to complete.
+Selama tur ini anda akan menemukan sekumpulan slide dan latihan untuk anda
+kerjakan.
-You can navigate through them using
+Anda bisa menavigasinya lewat
-- [[javascript:highlight(".prev-page")]["previous"]] or `PageUp` to go to the previous page,
+- [[javascript:highlight(".prev-page")]["sebelum"]] atau `PageUp` untuk kembali ke halaman sebelumnya,
-- [[javascript:highlight(".next-page")]["next"]] or `PageDown` to go to the next page.
+- [[javascript:highlight(".next-page")]["selanjutnya"]] atau `PageDown` untuk ke halaman selanjutnya.
-The tour is interactive. Click the
-[[javascript:highlightAndClick("#run")][Run]] button now
-(or press `Shift` + `Enter`) to compile and run the program on
-#appengine: a remote server.
-your computer.
-The result is displayed below the code.
+Tur ini interaktif. Klik pada tombol
+[[javascript:highlightAndClick("#run")][Jalan]]
+sekarang (atau tekan `Shift` + `Enter`) untuk mengkompilasi dan menjalankan
+program pada
+#appengine: server.
+komputer anda.
+Hasilnya akan ditampilkan di kanan bawah.
-These example programs demonstrate different aspects of Go. The programs in the tour are meant to be starting points for your own experimentation.
+Contoh program tersebut menampilkan aspek dari Go.
+Program yang ada di tur ditujukan sebagai titik awal bagi eksperimen anda.
-Edit the program and run it again.
+Ubah program tersebut dan jalankan lagi.
-When you click on [[javascript:highlightAndClick("#format")][Format]]
-(shortcut: `Ctrl` + `Enter`), the text in the editor is formatted using the
-[[https://golang.org/cmd/gofmt/][gofmt]] tool. You can switch syntax highlighting on and off
-by clicking on the [[javascript:highlightAndClick(".syntax-checkbox")][syntax]] button.
+Saat anda mengklik pada tombol
+[[javascript:highlightAndClick("#format")][Format]]
+(atau `Ctrl` + `Enter`), teks di bagian editor akan diformat menggunakan alat
+[[https://golang.org/cmd/gofmt/][gofmt]].
+Anda bisa menghidup atau mematikan sintaks dengan mengklik pada tombol
+[[javascript:highlightAndClick(".syntax-checkbox")][sintaks]]
-When you're ready to move on, click the [[javascript:highlightAndClick(".next-page")][right arrow]] below or type the `PageDown` key.
+Anda bisa mengaktifkan pewarnaan sintaks dengan mengklik pada tombol
+[[javascript:highlightAndClick(".syntax-checkbox")][sintaks]].
+
+Saat anda selesai, klik
+[[javascript:highlightAndClick(".next-page")][panah kanan]]
+di bawah atau tekan `PageDown`.
.play welcome/hello.go
-* Go local
+* Go Lokal
-The tour is available in other languages:
+Tur ini tersedia dalam beberapa bahasa:
- [[https://go-tour-br.appspot.com/][Brazilian Portuguese — Português do Brasil]]
- [[https://go-tour-ca.appspot.com/][Catalan — Català]]
- [[https://tour.go-zh.org/][Simplified Chinese — 中文(简体)]]
- [[https://go-tour-cz.appspot.com/][Czech — Česky]]
+- [[https://tour.golang.org/][English - English]]
- [[https://go-tour-fr.appspot.com/][French — Français]]
- [[https://go-tour-id2.appspot.com/][Indonesian — Bahasa Indonesia]]
- [[https://go-tour-jp.appspot.com/][Japanese — 日本語]]
@@ -59,49 +71,67 @@ The tour is available in other languages:
- [[https://go-tour-th.appspot.com/][Thai — ภาษาไทย]]
- [[https://go-tour-uz.appspot.com/][Uzbek — Ўзбекча]]
-Click the [[javascript:highlightAndClick(".next-page")]["next"]] button or type `PageDown` to continue.
+Klik tombol
+[[javascript:highlightAndClick(".next-page")]["selanjutnya"]]
+atau tekan `PageDown` untuk melanjutkan.
-#appengine: * Go offline (optional)
-#appengine:
-#appengine: This tour is also available as a stand-alone program that you can use
-#appengine: without access to the internet. It builds and runs the code samples on
-#appengine: your own machine.
+#appengine: * Go offline (opsional)
#appengine:
-#appengine: To run the tour locally, you'll need to first
-#appengine: [[https://golang.org/doc/install][install Go]] and then run:
+#appengine: Tur ini juga tersedia dalam program yang berjalan tersendiri yang
+#appengine: dapat anda gunakan tanpa akses internet.
+#appengine: Ia akan membuat dan menjalankan contoh kode di dalam mesin Anda
+#appengine: sendiri.
#appengine:
-#appengine: go get golang.org/x/tour
+#appengine: Untuk dapat menjalakan tur secara lokal, pertama
+#appengine: [[https://golang.org/dl/][unduh and pasang Go]]
+#appengine: kemudian jalankan program tour dengan cara,
#appengine:
-#appengine: This will place a `tour` binary in your
-#appengine: [[https://golang.org/doc/code.html#Workspaces][workspace]]'s `bin` directory.
-#appengine: When you run the tour program, it will open a web browser displaying
-#appengine: your local version of the tour.
+#appengine: go get github.com/golang-id/tour
#appengine:
-#appengine: Of course, you can continue to take the tour through this web site.
+#appengine: Perintah tersebut akan memasang program `tour` di dalam direktori
+#appengine: `bin` di
+#appengine: [[https://golang.org/doc/code.html#Workspaces][ruang kerja]]
+#appengine: Anda.
+#appengine: Saat Anda menjalankan program `tour`, ia akan membuka peramban web
+#appengine: yang menampilkan versi lokal dari tur.
+#appengine:
+#appengine: Tentu saja, anda bisa melanjutkan tur di situs ini.
-#appengine: * The Go Playground
-#appengine:
-#appengine: This tour is built atop the [[https://play.golang.org/][Go Playground]], a
-#appengine: web service that runs on [[https://golang.org/][golang.org]]'s servers.
+#appengine: * Go Playground
+#appengine:
+#appengine: Tur ini dibuat dengan
+#appengine: [[https://play.golang.org/][Go Playground]],
+#appengine: sebuah layanan web yang berjalan di atas server
+#appengine: [[https://golang.org/][golang.org]].
#appengine:
-#appengine: The service receives a Go program, compiles, links, and runs the program inside
-#appengine: a sandbox, then returns the output.
+#appengine: Layanan tersebut menerima program Go, mengkompilasi, dan
+#appengine: menjalankan program di dalam _sandbox_, dan mengembalikan
+#appengine: keluaran.
#appengine:
-#appengine: There are limitations to the programs that can be run in the playground:
+#appengine: Ada beberapa batasan untuk program yang berjalan di _playground_:
#appengine:
-#appengine: - In the playground the time begins at 2009-11-10 23:00:00 UTC (determining the significance of this date is an exercise for the reader). This makes it easier to cache programs by giving them deterministic output.
+#appengine: - Di _playground_ waktu dimulai dari 2009-11-10 23:00:00 UTC
+#appengine: (mengetahui kenapa menggunakan tanggal tersebut adalah latihan
+#appengine: bagi pembaca).
+#appengine: Hal ini membuat program lebih mudah di- _cache_ dengan memberikan
+#appengine: nilai keluaran yang pasti.
#appengine:
-#appengine: - There are also limits on execution time and on CPU and memory usage, and the program cannot access external network hosts.
+#appengine: - Waktu eksekusi, penggunaan CPU, dan _memory_ juga memiliki
+#appengine: batasan, dan program tidak dapat mengakses jaringan eksternal.
#appengine:
-#appengine: The playground uses the latest stable release of Go.
+#appengine: _Playground_ menggunakan rilis stabil dari Go.
#appengine:
-#appengine: Read "[[https://blog.golang.org/playground][Inside the Go Playground]]" to learn more.
+#appengine: Bacalah "
+#appengine: [[https://blog.golang.org/playground][Inside the Go Playground]]
+#appengine: " untuk belajar lebih lanjut.
#appengine:
#appengine: .play welcome/sandbox.go
-* Congratulations
+* Selamat
-You've finished the first module of the tour!
+Anda telah menyelesaikan modul pertama dari tur!
-Now click on [[javascript:highlightAndClick(".logo")][A Tour of Go]] to find out what else
-you can learn about Go, or go directly to the [[javascript:click('.next-page')][next lesson]].
+Sekarang klik pada
+[[javascript:highlightAndClick(".logo")][Tur Bahasa Pemrograman Go]]
+untuk menemukan apa saja yang dapat anda pelajari tentang Go, atau langsung ke
+[[javascript:click(".next-page")][pelajaran selanjutnya]].
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())
}
diff --git a/go.mod b/go.mod
index ceb57a7..c3eacb9 100644
--- a/go.mod
+++ b/go.mod
@@ -1,5 +1,15 @@
-module golang.org/x/tour
+module github.com/golang-id/tour
-go 1.11
+go 1.18
-require golang.org/x/tools v0.1.3-0.20210525215409-a3eb095d6aee
+require (
+ golang.org/x/tools v0.6.0
+ golang.org/x/tour v0.1.0
+)
+
+require (
+ github.com/yuin/goldmark v1.5.4 // indirect
+ golang.org/x/mod v0.8.0 // indirect
+ golang.org/x/net v0.7.0 // indirect
+ golang.org/x/sys v0.5.0 // indirect
+)
diff --git a/go.sum b/go.sum
index f2eedd1..44de699 100644
--- a/go.sum
+++ b/go.sum
@@ -1,29 +1,12 @@
-github.com/yuin/goldmark v1.3.5 h1:dPmz1Snjq0kmkz159iL7S6WzdahUTHnHB5M56WFVifs=
-github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
-golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
-golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
-golang.org/x/mod v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo=
-golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
-golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
-golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
-golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4 h1:4nGaVu0QrbjT/AK2PRLuQfQuh6DJve+pELhqTdAj3x0=
-golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
-golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
-golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
-golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
-golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20210510120138-977fb7262007 h1:gG67DSER+11cZvqIMb8S8bt0vZtiN6xWYARwirrOSfE=
-golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
-golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
-golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
-golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
-golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
-golang.org/x/tools v0.1.3-0.20210525215409-a3eb095d6aee h1:qoXIhA/wpnHg2z8RiA/rZb66+iiULmKyO9olVAU+GfU=
-golang.org/x/tools v0.1.3-0.20210525215409-a3eb095d6aee/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
-golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
-golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
-golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
-golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
+github.com/yuin/goldmark v1.5.4 h1:2uY/xC0roWy8IBEGLgB1ywIoEJFGmRrX21YQcvGZzjU=
+github.com/yuin/goldmark v1.5.4/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
+golang.org/x/mod v0.8.0 h1:LUYupSeNrTNCGzR/hVBk2NHZO4hXcVaW1k4Qx7rjPx8=
+golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
+golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g=
+golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
+golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU=
+golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/tools v0.6.0 h1:BOw41kyTf3PuCW1pVQf8+Cyg8pMlkYB1oo9iJ6D/lKM=
+golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
+golang.org/x/tour v0.1.0 h1:OWzbINRoGf1wwBhKdFDpYwM88NM0d1SL/Nj6PagS6YE=
+golang.org/x/tour v0.1.0/go.mod h1:DUZC6G8mR1AXgXy73r8qt/G5RsefKIlSj6jBMc8b9Wc=
diff --git a/local.go b/local.go
index 076cf94..9a2f7f6 100644
--- a/local.go
+++ b/local.go
@@ -25,12 +25,13 @@ import (
"golang.org/x/tools/playground/socket"
// Imports so that go build/install automatically installs them.
- _ "golang.org/x/tour/pic"
- _ "golang.org/x/tour/tree"
- _ "golang.org/x/tour/wc"
+ _ "github.com/golang-id/tour/pic"
+ _ "github.com/golang-id/tour/tree"
+ _ "github.com/golang-id/tour/wc"
)
const (
+ basePkg = "github.com/golang-id/tour"
socketPath = "/socket"
)
@@ -60,7 +61,7 @@ func isRoot(path string) bool {
func findRoot() (string, bool) {
// Try finding the golang.org/x/tour package in the
// legacy GOPATH mode workspace or in build list.
- p, err := build.Import("golang.org/x/tour", "", build.FindOnly)
+ p, err := build.Import(basePkg, "", build.FindOnly)
if err == nil && isRoot(p.Dir) {
return p.Dir, true
}
@@ -71,7 +72,7 @@ func findRoot() (string, bool) {
// In that's the case, find out what version it is,
// and access its content from the module cache.
if info, ok := debug.ReadBuildInfo(); ok &&
- info.Main.Path == "golang.org/x/tour" &&
+ info.Main.Path == basePkg &&
info.Main.Replace == nil &&
info.Main.Version != "(devel)" {
// Make some assumptions for brevity:
@@ -80,7 +81,7 @@ func findRoot() (string, bool) {
// • the version isn't "(devel)"
// They should hold for the use cases we care about, until this
// entire mechanism is obsoleted by file embedding.
- out, execError := exec.Command("go", "mod", "download", "-json", "--", "golang.org/x/tour@"+info.Main.Version).Output()
+ out, execError := exec.Command("go", "mod", "download", "-json", "--", basePkg+`@`+info.Main.Version).Output()
var tourRoot struct{ Dir string }
jsonError := json.Unmarshal(out, &tourRoot)
if execError == nil && jsonError == nil && isRoot(tourRoot.Dir) {
diff --git a/pic/pic.go b/pic/pic.go
index f60ba0e..2e187a8 100644
--- a/pic/pic.go
+++ b/pic/pic.go
@@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// Package pic implements functions that
-// display pictures on the Go playground.
-package pic // import "golang.org/x/tour/pic"
+// Package pic mengimplementasikan fungsi untuk menampilkan gambar di
+// Go Playground.
+package pic // import "github.com/golang-id/tour/pic"
import (
"bufio"
@@ -15,15 +15,12 @@ import (
"os"
)
-// Show displays a picture defined by the function f
-// when executed on the Go Playground.
+// Show menampilkan gambar dari fungsi f saat di eksekusi di Go Playground.
//
-// f should return a slice of length dy,
-// each element of which is a slice of dx
-// 8-bit unsigned int. The integers are
-// interpreted as bluescale values,
-// where the value 0 means full blue,
-// and the value 255 means full white.
+// f mengembalikan sebuah slice dengan panjang dy, setiap elemen dari slice
+// tersebut adalah sebuah slice dx, 8-bit unsigned int.
+// Nilai integer diinterpretasikan sebagai nilai rentang warna biru, yang
+// mana nilai 0 berarti biru, dan 255 berwarna putih.
func Show(f func(dx, dy int) [][]uint8) {
const (
dx = 256
diff --git a/reader/validate.go b/reader/validate.go
index 5d3a2c2..486c9d9 100644
--- a/reader/validate.go
+++ b/reader/validate.go
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-package reader // import "golang.org/x/tour/reader"
+package reader // import "github.com/golang-id/tour/reader"
import (
"fmt"
diff --git a/solutions/binarytrees.go b/solutions/binarytrees.go
index 2ba3604..fe47542 100644
--- a/solutions/binarytrees.go
+++ b/solutions/binarytrees.go
@@ -9,7 +9,7 @@ package main
import (
"fmt"
- "golang.org/x/tour/tree"
+ "github.com/golang-id/tour/tree"
)
func walkImpl(t *tree.Tree, ch chan int) {
diff --git a/solutions/binarytrees_quit.go b/solutions/binarytrees_quit.go
index 076bd66..a469767 100644
--- a/solutions/binarytrees_quit.go
+++ b/solutions/binarytrees_quit.go
@@ -9,7 +9,7 @@ package main
import (
"fmt"
- "golang.org/x/tour/tree"
+ "github.com/golang-id/tour/tree"
)
func walkImpl(t *tree.Tree, ch, quit chan int) {
diff --git a/solutions/image.go b/solutions/image.go
index 60d9c5e..bdba7af 100644
--- a/solutions/image.go
+++ b/solutions/image.go
@@ -10,7 +10,7 @@ import (
"image"
"image/color"
- "golang.org/x/tour/pic"
+ "github.com/golang-id/tour/pic"
)
type Image struct {
diff --git a/solutions/maps.go b/solutions/maps.go
index ddd6b52..f2565a0 100644
--- a/solutions/maps.go
+++ b/solutions/maps.go
@@ -9,7 +9,7 @@ package main
import (
"strings"
- "golang.org/x/tour/wc"
+ "github.com/golang-id/tour/wc"
)
func WordCount(s string) map[string]int {
diff --git a/solutions/readers.go b/solutions/readers.go
index 278cd65..ba7036d 100644
--- a/solutions/readers.go
+++ b/solutions/readers.go
@@ -6,7 +6,7 @@
package main
-import "golang.org/x/tour/reader"
+import "github.com/golang-id/tour/reader"
type MyReader struct{}
diff --git a/solutions/slices.go b/solutions/slices.go
index 37bf9b3..d66ed02 100644
--- a/solutions/slices.go
+++ b/solutions/slices.go
@@ -6,7 +6,7 @@
package main
-import "golang.org/x/tour/pic"
+import "github.com/golang-id/tour/pic"
func Pic(dx, dy int) [][]uint8 {
p := make([][]uint8, dy)
diff --git a/static/css/app.css b/static/css/app.css
index e2f2ffd..e72d38b 100755..100644
--- a/static/css/app.css
+++ b/static/css/app.css
@@ -411,6 +411,7 @@ a#run, a#kill {
}
#left-side {
background: #e0ebf5;
+ padding-top: 120px;
}
#right-side {
padding-top: 48px;
@@ -527,3 +528,14 @@ a#run, a#kill {
display: none;
}
}
+@media (max-width: 960px) {
+ #explorer {
+ position: initial;
+ height: auto;
+ }
+ #explorer .imports-checkbox,
+ #explorer .syntax-checkbox {
+ float: none;
+ display: block;
+ }
+}
diff --git a/static/js/app.js b/static/js/app.js
index 7127bfc..7127bfc 100755..100644
--- a/static/js/app.js
+++ b/static/js/app.js
diff --git a/static/js/controllers.js b/static/js/controllers.js
index f3b9cf7..f3b9cf7 100755..100644
--- a/static/js/controllers.js
+++ b/static/js/controllers.js
diff --git a/static/js/directives.js b/static/js/directives.js
index d7eb9bc..d7eb9bc 100755..100644
--- a/static/js/directives.js
+++ b/static/js/directives.js
diff --git a/static/js/services.js b/static/js/services.js
index da5f79c..da5f79c 100755..100644
--- a/static/js/services.js
+++ b/static/js/services.js
diff --git a/static/js/values.js b/static/js/values.js
index 1c24ddc..11a124e 100644
--- a/static/js/values.js
+++ b/static/js/values.js
@@ -1,4 +1,4 @@
-/* Copyright 2012 The Go Authors. All rights reserved.
+/* Copyright 2012-2015 The Go Authors. All rights reserved.
* Use of this source code is governed by a BSD-style
* license that can be found in the LICENSE file.
*/
@@ -9,50 +9,50 @@ angular.module('tour.values', []).
// List of modules with description and lessons in it.
value('tableOfContents', [{
'id': 'mechanics',
- 'title': 'Using the tour',
- 'description': '<p>Welcome to a tour of the <a href="https://golang.org">Go programming language</a>. The tour covers the most important features of the language, mainly:</p>',
+ 'title': 'Penggunaan Tur',
+ 'description': '<p>Selamat datang di tur <a href="https://golang.org">bahasa pemrograman Go</a>. Tur ini melingkupi fitur paling penting dari bahasa, pada umumnya:</p>',
'lessons': ['welcome']
}, {
'id': 'basics',
- 'title': 'Basics',
- 'description': '<p>The starting point, learn all the basics of the language.</p><p>Declaring variables, calling functions, and all the things you need to know before moving to the next lessons.</p>',
+ 'title': 'Dasar',
+ 'description': '<p>Langkah awal, pelajari semua dasar bahasa.</p><p>Deklarasi variabel, pemanggilan fungsi, dan semua hal yang perlu anda ketahui sebelum pindah ke pelajaran selanjutnya.</p>',
'lessons': ['basics', 'flowcontrol', 'moretypes']
}, {
'id': 'methods',
- 'title': 'Methods and interfaces',
- 'description': '<p>Learn how to define methods on types, how to declare interfaces, and how to put everything together.</p>',
+ 'title': 'Method dan interface',
+ 'description': '<p>Belajar cara mendefinisikan method pada tipe, cara deklarasi interface, dan cara menggabungkan keduanya.</p>',
'lessons': ['methods']
}, {
'id': 'concurrency',
- 'title': 'Concurrency',
- 'description': '<p>Go provides concurrency features as part of the core language.</p><p>This module goes over goroutines and channels, and how they are used to implement different concurrency patterns.</p>',
+ 'title': 'Konkurensi',
+ 'description': '<p>Go menyediakan fitur konkurensi sebagai bagian dari inti bahasa.</p><p>Modul ini mempelajari goroutines dan channels, dan cara menggunakannya pada pola konkurensi yang berbeda.</p>',
'lessons': ['concurrency']
}]).
// translation
value('translation', {
- 'off': 'off',
- 'on': 'on',
- 'syntax': 'Syntax-Highlighting',
- 'lineno': 'Line-Numbers',
+ 'off': 'hidup',
+ 'on': 'nyala',
+ 'syntax': 'Penekanan-Sintaks',
+ 'lineno': 'Nomor-Baris',
'reset': 'Reset Slide',
- 'format': 'Format Source Code',
- 'kill': 'Kill Program',
- 'run': 'Run',
- 'compile': 'Compile and Run',
- 'more': 'Options',
- 'toc': 'Table of Contents',
- 'prev': 'Previous',
- 'next': 'Next',
- 'waiting': 'Waiting for remote server...',
- 'errcomm': 'Error communicating with remote server.',
- 'submit-feedback': 'Send feedback about this page',
+ 'format': 'Format Sumber Kode',
+ 'kill': 'Matikan Program',
+ 'run': 'Jalankan',
+ 'compile': 'Kompilasi dan Jalankan',
+ 'more': 'Opsi',
+ 'toc': 'Daftar Isi',
+ 'prev': 'Sebelumnya',
+ 'next': 'Selanjutnya',
+ 'waiting': 'Menunggu server...',
+ 'errcomm': 'Kesalahan komunikasi dengan server.',
+ 'submit-feedback': 'Kirim umpan-balik tentang halaman ini',
// GitHub issue template: update repo and messaging when translating.
- 'github-repo': 'github.com/golang/tour',
- 'issue-title': 'tour: [REPLACE WITH SHORT DESCRIPTION]',
- 'issue-message': 'Change the title above to describe your issue and add your feedback here, including code if necessary',
- 'context': 'Context',
+ 'github-repo': 'github.com/golang-id/tour',
+ 'issue-title': 'tur: [GANTI DENGAN DESKRIPSI SINGKAT]',
+ 'issue-message': 'Ganti judul di atas dan jelaskan isu yang anda hadapi di sini, ikutkan kode jika diperlukan',
+ 'context': 'Konteks',
}).
// Config for codemirror plugin
diff --git a/static/partials/editor.html b/static/partials/editor.html
index 15b6e20..d5044ef 100644
--- a/static/partials/editor.html
+++ b/static/partials/editor.html
@@ -16,7 +16,7 @@
<div id="right-side" class="relative-content">
<div id="explorer" ng-class="{hidden: toc.lessons[lessonId].Pages[curPage-1].Files.length==0}">
<a class="menu-button" ng-repeat="f in toc.lessons[lessonId].Pages[curPage-1].Files" ng-click="openFile($index)" ng-class="{active: $index==curFile}">{{f.Name}}</a>
- <a syntax-checkbox ng-class="{active: editor.syntax}" class="menu-button syntax-checkbox">Syntax</a>
+ <a syntax-checkbox ng-class="{active: editor.syntax}" class="menu-button syntax-checkbox">Sintaks</a>
<a imports-checkbox ng-class="{active: editor.imports}" class="menu-button imports-checkbox">Imports</a>
</div>
@@ -36,8 +36,8 @@
<div class="relative-content">
<!--div id="file-menu" ng-controller="OutputCtrl"-->
<div id="file-menu">
- <a ng-show="job == null" class="menu-button" id="run" ng-click="run()">Run</a>
- <a ng-show="job != null" class="menu-button" id="kill" ng-click="kill()">Kill</a>
+ <a ng-show="job == null" class="menu-button" id="run" ng-click="run()">Jalankan</a>
+ <a ng-show="job != null" class="menu-button" id="kill" ng-click="kill()">Hentikan</a>
<a class="menu-button" id="format" ng-click="format()">Format</a>
<a class="menu-button" id="reset" ng-click="reset()">Reset</a>
</div>
diff --git a/static/partials/list.html b/static/partials/list.html
index 7cf93cf..f257233 100644
--- a/static/partials/list.html
+++ b/static/partials/list.html
@@ -2,7 +2,7 @@
<div class="container">
<div class="page-header">
- <h1>Welcome to a tour of Go</h1>
+ <h1>Selamat datang di tur bahasa pemrograman Go</h1>
</div>
<div class="module" ng-repeat="m in toc.modules">
diff --git a/template/index.tmpl b/template/index.tmpl
index 837dc77..5c09374 100755
--- a/template/index.tmpl
+++ b/template/index.tmpl
@@ -15,7 +15,7 @@
<body>
<div class="bar top-bar">
- <a class="left logo" href="/list">A Tour of Go</a>
+ <a class="left logo" href="/list">Tur Bahasa Pemrograman Go</a>
<div table-of-contents-button=".toc"></div>
<div feedback-button></div>
</div>
diff --git a/tour.go b/tour.go
index b27fc50..c3c2a59 100644
--- a/tour.go
+++ b/tour.go
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-package main // import "golang.org/x/tour"
+package main // import "github.com/golang-id/tour"
import (
"bytes"
diff --git a/tree/tree.go b/tree/tree.go
index 4dfa76c..e610449 100644
--- a/tree/tree.go
+++ b/tree/tree.go
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-package tree // import "golang.org/x/tour/tree"
+package tree // import "github.com/golang-id/tour/tree"
import (
"fmt"
diff --git a/wc/wc.go b/wc/wc.go
index 94acf1a..9fe1977 100644
--- a/wc/wc.go
+++ b/wc/wc.go
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-package wc // import "golang.org/x/tour/wc"
+package wc // import "github.com/golang-id/tour/wc"
import "fmt"