I just started dorking around with Go....just got interested as I am about to embark on writing some microservices and reading up on the architecture and just research led me to Go...would love to hear some personal experiences that some here may have had.
share some more about that "Go"
Go provides two features that replace class inheritance.
The first is embedding, which can be viewed as an automated form of composition or delegation.
The second are its interfaces, which provides runtime polymorphism. Interfaces are a class of types and provide a limited form of structural typing in the otherwise nominal type system of Go. An object which is of an interface type is also of another type, much like C++ objects being simultaneously of a base and derived class. Go interfaces were designed after protocols from the Smalltalk programming language. Multiple sources use the term duck typing when describing Go interfaces. Although the term duck typing is not precisely defined and therefore not wrong, it usually implies that type conformance is not statically checked. Since conformance to a Go interface is checked statically by the Go compiler (except when performing a type assertion), the Go authors prefer the term structural typing.
The definition of an interface type lists required methods by name and type. Any object of type T for which functions exist matching all the required methods of interface type I is an object of type I as well. The definition of type T need not (and cannot) identify type I. For example, if Shape, Square and Circle are defined as:
import “math” :cobra:
will that do?
Coming from a mainframe PL/1 PL/C and C, Basic, Pascal background… and Having skip Java and jump in to Scala and Python…I found Go to be really cool, simple and nimble…it is a fun language…setting up channels, webserver, listener ports etc etc are pretty simple to do…
Here is a UNIX echo command implementation in go:
// Echo1 prints its command-line arguments//
package main
import ( “fmt” “os” ) func main() {
var s, sep string
for i := 1; i < len(os.Args); i++{
s += sep + os.Args*
sep = " "
} fmt.Println(s)
}