# Pointer pada Method

Pointer dapat digunakan di method jika ingin mengubah nilai dari variabel yang memiliki method tersebut secara permanen.

## Contoh code pointer pada method sebuah string

```go
package main
import "fmt"

type str string

func (s *str) Update1() {
	*s = "member_02"
}

func (s str) Update2() {
	s = "member_03"
}

func main() {
	var name str = "member_01"
	name.Update1()
	name.Update2()
	fmt.Println(name)
}


```

```
member_02
```

## Contoh code pointer pada method sebuah struct

```go
package main

import (
    "fmt"
)

type Man struct{
    Name string
}

func (m *Man) Test1() {
    m.Name = "member_02"
    fmt.Println(*m)
}

func (m Man) Test2() {
    m.Name = "member_03"
    fmt.Println(m)
}

func (m Man) Test3() {
    fmt.Println(m)
}

func main() {
    member_01 := Man{"member_01"}
    fmt.Println(member_01)
    member_01.Test1()
    member_01.Test2()
    member_01.Test3()
    
    fmt.Println(member_01)
}
```

```
{member_01}
{member_02}
{member_03}
{member_02}
{member_02}
```


---

# Agent Instructions: 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/pointer/pointer-pada-method.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.
