This repository has been archived by the owner on Jul 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 645
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix signature for methods extending structs
- Loading branch information
1 parent
d0c6671
commit 73dbfc4
Showing
5 changed files
with
104 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package abc | ||
|
||
import ( | ||
"fmt" | ||
"math" | ||
"net" | ||
) | ||
|
||
// ABC is a struct, you coudnt use Goto Definition or Hover info on this before | ||
// Now you can due to gogetdoc | ||
type ABC struct { | ||
a int | ||
b int | ||
c int | ||
} | ||
|
||
// This is an unexported function so couldnt get this comment on hover :( | ||
// Not anymore!! gogetdoc to the rescue | ||
func print(txt string) { | ||
fmt.Println(txt) | ||
} | ||
|
||
func main() { | ||
print("Hello") | ||
} | ||
|
||
// Hello is a method on the struct ABC. Will signature help understand this correctly | ||
func (abcd *ABC) Hello(s string, exclaim bool) string { | ||
net.CIDRMask(1, 2) | ||
if exclaim { | ||
s = s + "!" | ||
} | ||
if abcd.a+abcd.b+abcd.c > 3 { | ||
return "Hello " + s | ||
} | ||
return "GoodBye " + s | ||
} | ||
|
||
// Greetings is an exported function. So all is good. | ||
func Greetings() string { | ||
xyz := ABC{1, 2, int(math.Abs(-1))} | ||
return xyz.Hello("World", false) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters