Go: Getting Started

Open a new file main.go name. Relationship with Package . We can enter the func code for the function. Println code written for taking a result. If we write const code on the func main we can write message and open in it.Also var () code is working for the same way to write message string and get the same solution.Write import (“fmt”) and enter before println code fmt. code.

Write go run main.go code on terminal to work and get result.

DATA TYPES AND OPERATIONS

Primitive Data TypesmyInt=enter the number in type of int and we get result on var myFloat32 float 32

Constants (Sabit) → We enter the const ( ) code that when we write numbers it shows the result on written number. If we enter iota code ,it get the result zero the first number and later it begin to the numbers automaticly.

Collections myArray := this code run for when we can get all number that we give,get in one line and for result enter println code. In Println when we write len(myArray) code, we can get the length. mySlice := code is the same work like array (define Float32 )

Arithmetic Operators →For the operation like add subtract remainder , use add := and write println(add) to get the result. inc := 1 inc++ code to get increase numbers by one by.

Branching and Looping

Branches →For example of code foo := 1 and write in if command and foo ==1 println(“bar”) code to get result.

Loops s :=[]string{write want you want} for idx, v:= range s { println(idx ,v) } code for what we want to get with the number in front.

Functions

Functions and Parameters → First we write sayHello in func (“write messages side by side that you want”).On second func part, write sayHello(message …string) with the command of for_, message := range message So that gives you all the messages we enter the lower by lower.

Anonymous Functions →

Objected-Oriented Programming

Structs and Fields → Begin to “fmt” import code . Write foo := &myStruct{“bar”} code and enter the code type myStruct struct { myField string} to get the result of &{bar} .To get result the same what we written in it.

Constructor Functions → The parameter that determines the fields of the objects that are created.Enter the code type myStruct struct {myMap map[string]string }.On the func part create a newMyStruct() *myStruct and relate with the result.myMap =map[string]string{} .In this way all the values entered in this field appear in their fields.

Methods → In mp := messagePrinter (“…”) mp.printMessage() code to get result for what we written in message.

Object Composition → In emp := enhancedMessagePrinter {} hide the message like {messagePrinter{“..”}} to get the same result.

ibrahim ÇOBANİ

Show your support

Clapping shows how much you appreciated Salvo Babani⭐️⭐️⭐️⭐️’s story.