# Methods: https://play.golang.org/p/AKrvuxF0wMK

**URL:** <https://forum.golangbridge.org/t/methods-https-play-golang-org-p-akrvuxf0wmk/11906>\
**Category:** Getting Help\
**Created:** [December 22, 2018, 1:38pm UTC](https://forum.golangbridge.org/t/methods-https-play-golang-org-p-akrvuxf0wmk/11906 "2018-12-22T13:38:24Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![cherilexvold1974](https://forum.golangbridge.org/user_avatar/forum.golangbridge.org/cherilexvold1974/32/4270_2.png) [@cherilexvold1974](https://forum.golangbridge.org/u/cherilexvold1974)\
**Post date:** [December 22, 2018, 1:38pm UTC](https://forum.golangbridge.org/t/methods-https-play-golang-org-p-akrvuxf0wmk/11906/1 "2018-12-22T13:38:24Z")

</div>

In this program: [https://play.golang.org/p/AKrvuxF0wMK](https://play.golang.org/p/AKrvuxF0wMK)  
is (s secretAgent).  
Is the “s” here anywhere else in the program? What is the significance of “s”?

---

<div class="post-metadata">

**Author:** ![cherilexvold1974](https://forum.golangbridge.org/user_avatar/forum.golangbridge.org/cherilexvold1974/32/4270_2.png) [@cherilexvold1974](https://forum.golangbridge.org/u/cherilexvold1974)\
**Post date:** [December 22, 2018, 1:41pm UTC](https://forum.golangbridge.org/t/methods-https-play-golang-org-p-akrvuxf0wmk/11906/2 "2018-12-22T13:41:21Z")

</div>

Are ther any returns in this program? And if so, what are they?

---

<div class="post-metadata">

**Author:** ![cherilexvold1974](https://forum.golangbridge.org/user_avatar/forum.golangbridge.org/cherilexvold1974/32/4270_2.png) [@cherilexvold1974](https://forum.golangbridge.org/u/cherilexvold1974)\
**Post date:** [December 22, 2018, 1:42pm UTC](https://forum.golangbridge.org/t/methods-https-play-golang-org-p-akrvuxf0wmk/11906/3 "2018-12-22T13:42:48Z")

</div>

Oh gosh, I see “s” now, here: s.first, s.last

---

<div class="post-metadata">

**Author:** ![cherilexvold1974](https://forum.golangbridge.org/user_avatar/forum.golangbridge.org/cherilexvold1974/32/4270_2.png) [@cherilexvold1974](https://forum.golangbridge.org/u/cherilexvold1974)\
**Post date:** [December 22, 2018, 1:58pm UTC](https://forum.golangbridge.org/t/methods-https-play-golang-org-p-akrvuxf0wmk/11906/4 "2018-12-22T13:58:10Z")

</div>

Anyone have a definition of “receiver”?  
Also, a definition of "return?  
I found this: Return statements

A “return” statement in a function `F` terminates the execution of `F` , and optionally provides one or more result values. Any functions [deferred](https://golang.org/ref/spec#Defer_statements) by `F` are executed before `F` returns to its caller. (Language Specification)

Is this what he’s referring to? Can anyone elaborate?

I can’t find “receiver”.

---

<div class="post-metadata">

**Author:** ![Cecil\_New](https://forum.golangbridge.org/user_avatar/forum.golangbridge.org/cecil_new/32/1149_2.png) [@Cecil\_New](https://forum.golangbridge.org/u/Cecil_New)\
**Post date:** [December 22, 2018, 3:21pm UTC](https://forum.golangbridge.org/t/methods-https-play-golang-org-p-akrvuxf0wmk/11906/5 "2018-12-22T15:21:14Z")

</div>

Methods are functions bound to a struct. The receiver is a parenthetical spec of the struct instance name so it can be used inside the function. So methods have receivers; pure functions do not. More at the link below.

A return statement is how a function or method returns any values to the caller. If you are asking about the “defer” bit, then lookup the defer in the language spec for details.

[https://golang.org/doc/effective\_go.html#pointers\_vs\_values](https://golang.org/doc/effective_go.html#pointers_vs_values)

---

<div class="post-metadata">

**Author:** ![cherilexvold1974](https://forum.golangbridge.org/user_avatar/forum.golangbridge.org/cherilexvold1974/32/4270_2.png) [@cherilexvold1974](https://forum.golangbridge.org/u/cherilexvold1974)\
**Post date:** [December 23, 2018, 3:48pm UTC](https://forum.golangbridge.org/t/methods-https-play-golang-org-p-akrvuxf0wmk/11906/6 "2018-12-23T15:48:38Z")

</div>

Thank-you

---

<div class="post-metadata">

**Author:** ![cherilexvold1974](https://forum.golangbridge.org/user_avatar/forum.golangbridge.org/cherilexvold1974/32/4270_2.png) [@cherilexvold1974](https://forum.golangbridge.org/u/cherilexvold1974)\
**Post date:** [December 23, 2018, 4:15pm UTC](https://forum.golangbridge.org/t/methods-https-play-golang-org-p-akrvuxf0wmk/11906/7 "2018-12-23T16:15:20Z")

</div>

I studied your information carefully and saved the definitions to a file.

---

<div class="post-metadata">

**Author:** ![cherilexvold1974](https://forum.golangbridge.org/user_avatar/forum.golangbridge.org/cherilexvold1974/32/4270_2.png) [@cherilexvold1974](https://forum.golangbridge.org/u/cherilexvold1974)\
**Post date:** [December 23, 2018, 4:35pm UTC](https://forum.golangbridge.org/t/methods-https-play-golang-org-p-akrvuxf0wmk/11906/8 "2018-12-23T16:35:19Z")

</div>

What are the returns in the code.

[https://play.golang.org/p/AKrvuxF0wMK](https://play.golang.org/p/AKrvuxF0wMK)

---

<div class="post-metadata">

**Author:** ![NobbZ](https://forum.golangbridge.org/user_avatar/forum.golangbridge.org/nobbz/32/3096_2.png) [@NobbZ](https://forum.golangbridge.org/u/NobbZ)\
**Post date:** [December 23, 2018, 9:52pm UTC](https://forum.golangbridge.org/t/methods-https-play-golang-org-p-akrvuxf0wmk/11906/9 "2018-12-23T21:52:16Z")

</div>

Do you see the `return` keyword anywhere? Okay, neither do I, so it seems there are none.

---

<div class="post-metadata">

**Author:** ![johandalabacka](https://forum.golangbridge.org/user_avatar/forum.golangbridge.org/johandalabacka/32/4477_2.png) [@johandalabacka](https://forum.golangbridge.org/u/johandalabacka)\
**Post date:** [December 23, 2018, 11:43pm UTC](https://forum.golangbridge.org/t/methods-https-play-golang-org-p-akrvuxf0wmk/11906/10 "2018-12-23T23:43:20Z")

</div>

Hi

A bound function can return values but yours doesn’t. It just prints some text. It works in the same way as regular functions

```go

func double(x int) int {
     return x * 2
}

```

The int after the ) tells the computer this function will return an int. And the return statement later will do this. On the other hand would a function which only printed some text maybe not return something and after the ) would there be nothing.

```go

func printDouble(x int) {
    fmt.Println(x * 2)
}

```

---

<div class="post-metadata">

**Author:** ![cherilexvold1974](https://forum.golangbridge.org/user_avatar/forum.golangbridge.org/cherilexvold1974/32/4270_2.png) [@cherilexvold1974](https://forum.golangbridge.org/u/cherilexvold1974)\
**Post date:** [December 24, 2018, 5:54pm UTC](https://forum.golangbridge.org/t/methods-https-play-golang-org-p-akrvuxf0wmk/11906/11 "2018-12-24T17:54:32Z")

</div>

Do you see the `return` keyword anywhere? Okay, neither do I, so it seems there are none.

Okay, so apparently from you said, the `return` keyword must be present fir there to be a return.

---

<div class="post-metadata">

**Author:** ![cherilexvold1974](https://forum.golangbridge.org/user_avatar/forum.golangbridge.org/cherilexvold1974/32/4270_2.png) [@cherilexvold1974](https://forum.golangbridge.org/u/cherilexvold1974)\
**Post date:** [December 24, 2018, 5:56pm UTC](https://forum.golangbridge.org/t/methods-https-play-golang-org-p-akrvuxf0wmk/11906/12 "2018-12-24T17:56:24Z")

</div>

Interesting. Thanks!

---

<div class="post-metadata">

**Author:** ![system](https://forum.golangbridge.org/uploads/default/original/2X/5/5ad234f7c3dbc68b6cc72d338ce4f2973d9fd81c.png) [@system](https://forum.golangbridge.org/u/system)\
**Post date:** [March 24, 2019, 5:56pm UTC](https://forum.golangbridge.org/t/methods-https-play-golang-org-p-akrvuxf0wmk/11906/13 "2019-03-24T17:56:25Z")

</div>

Closed on March 24, 2019, 5:56pm UTC

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
