WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

Go - Method


Go programming language Methods are special features with a receiver.

Syntax

func (variable_name variable_data_type) function_name() [return_type]
   /* function frame*/


Example

package deal principal

import (
   "fmt" 
   "math" 
)

/* outline a circle */
type Circle struct 
   x,y,radius float64


/* outline a way for circle */
func(circle Circle) vicinity() float64 
   return math.Pi * circle.Radius * circle.Radius


func main()
   circle := Circlex:0, y:zero, radius:4
   fmt.Printf("Circle region: %f", circle.Region())

$go run important.Go
Circle area: 50.265482