Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I write inline documentation for methods and variables in Go code?

is there some rules to document methods and variables in GO language?

for example on php

/**
 This method will increase parameter $b in 10 points
 @var int $b
 @return int

*/
public function someMethod($b){
    return $b+10;
}

is there something like that on GO, or there I must use only "// comment" above method without any @var or @return ?

like image 290
Unstaged Avatar asked Apr 24 '14 12:04

Unstaged


Video Answer


1 Answers

You should use standard // comments because this is what the official documentation tool called godoc will use to generate documentation for your go code. You can have a look at this post from the official golang blog about it: http://blog.golang.org/godoc-documenting-go-code

I also found this quite interesting: https://godoc.org/github.com/natefinch/godocgo

like image 178
Uraza Avatar answered Oct 25 '22 23:10

Uraza