Interface Type

Interface names conventions By convention, one-method interfaces are named by the method name plus an -er suffix. Define an interface type It start with the keyword “type” follow by the interface name (ended with -er). Begin of a block of code symbol “{“, the function name (eg. Greeting() function and return a string ). One… Continue reading Interface Type

Published
Categorized as Interface

Definition of GO Package

Go programs are organized into packages. A package is a collection of source files in the same directory that are compiled together. Functions, types, variables, and constants defined in one source file are visible to all other source files within the same package.

Published
Categorized as Language

Variadic Function

A variadic function accept varying numbers of arguments. To declare a variadic function, the type of of the final parameter is preceded by an ellipsis, “…” …int ellipsis defined a function can be called with any number of arguments of this type vals is []int slice, can be access this slice using index or for..range

Methods with Struct

The Point struct type has two fields, x and y of float64 A method is defined with use of the keyword “func” just like a definition of the function. Just after func keyword, the defined fields of struct used in the body of code of the function as a receiver. It takes a variable of… Continue reading Methods with Struct

Interface with abstract of methods

Defining an Interface Keyword : type, interface Interface_name user provide a descriptive name Within the { } curly bracket, method sets are a list of method_name has been defined method name with parameters, return. No implementation details. https://golang.org/pkg/os/#FileInfo the FileInfo interface has the following method sets: Name() string // return a string Size() int64 //… Continue reading Interface with abstract of methods

Struct type

Struct types A struct is a sequence of named elements, called fields, each of which has a name and a type. Field names may be specified explicitly (IdentifierList) or implicitly (EmbeddedField). Within a struct, non-blank field names must be unique. StructType = “struct” “{” { FieldDecl “;” } “}” . FieldDecl = (IdentifierList Type | EmbeddedField) [… Continue reading Struct type

Go Modules

A module is a collection of Go packages stored in a file tree with a go.mod file at its root. The go.mod file defines the module’s module path, which is also the import path used for the root directory, and its dependency requirements, which are the other modules needed for a successful build. From Go… Continue reading Go Modules

Published
Categorized as Language