> For the complete documentation index, see [llms.txt](https://rafli-ramadhan.gitbook.io/golang-example-code-by-topic/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://rafli-ramadhan.gitbook.io/golang-example-code-by-topic/default-value-setiap-tipe-data.md).

# Default Value setiap Tipe Data

Default value untuk setiap tipe data dirinci sebagai berikut:

1. Integer dan Unsigned Integer -> 0
2. Float dan Complex -> 0
3. String -> ""
4. Boolean -> false
5. Array -> menyesuaikan tipe data yang digunakan
6. Struct -> menyesuaikan tipe data dari setiap property di dalam struct &#x20;
7. Map -> nil
8. Slice -> nil
9. Function -> nil
10. Channel -> nil
11. Interface Kosong -> nil

Berikut merupakan code untuk mengetahui default value dari setiap tipe data seperti array, struct, slice, interface dan map.&#x20;

```go
package main

import(
	"fmt"
)

func main() {
	var arr [3]int
	fmt.Println(arr)

	type User struct {
		Name  string
		Age   int
	}
	var user User
	fmt.Println(user == User{})

	var exampleSlice []int
	fmt.Println(exampleSlice == nil)

	type error interface {
		Error() string
	}

	var err error
	fmt.Println(err == nil)

	var exampleMap map[string]int					
	fmt.Println(exampleMap == nil)

	var exampleMap2 map[string]int = map[string]int{}
	fmt.Println(exampleMap2 == nil)
}
```

```
[0 0 0]
{ 0}
true
[]
true
true
true
false
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://rafli-ramadhan.gitbook.io/golang-example-code-by-topic/default-value-setiap-tipe-data.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
