Skip to content

ussefT/go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

Go


install

Download and install file.In terminal

go version

About

The Go programming language is an open source project to make programmers more productive.

Go is expressive, concise, clean, and efficient. Its concurrency mechanisms make it easy to write programs that get the most out of multicore and networked machines, while its novel type system enables flexible and modular program construction. Go compiles quickly to machine code yet has the convenience of garbage collection and the power of run-time reflection. It's a fast, statically typed, compiled language that feels like a dynamically typed, interpreted language.


types

In go we have sign and unsign int, float

    
    var age1 int8
    var numb uint8

    var num2 int16
	var age2 uint16
	
    var numb3 int32
    var numb4 uint32

	var num float32
	var num float64

array

List with fix length

    var ages [3]uint8 =[3] uint8 {2,2,2}

	// length is fix
	names :=[4]string{"root","mario"}
	names[1]="foo"
	fmt.Println(ages,len(ages))

slice

slice can be change

    // define list
	var score=[]int {100,12}
	// change value
	score[1]=32
	// add to list
	score=append(score,23)

example

//slice range
	name:=[]int{1,2,3,4,5,6}
	rangeOne:=name[1:4]
	rangeTwo:=name[2:]
	rangeThre:=name[:2]

fmt

	age := 12

    numFloat:=222.22

	fmt.Print("Hello \n")

	fmt.Println("Hi",age,"end")

	fmt.Printf("age %d",age)

	fmt.Printf("age %f",numFloat)

strings

Work on strings

import (
	"fmt"
	"strings"
)

    greeting :="Hello world!"

	// return boolean
	contain:=strings.Contains(greeting,"Hello")
	fmt.Println(contain)

	replace:=strings.ReplaceAll(greeting,"Hello","hi")

	toUpper:=strings.ToUpper(greeting)

	// return index word in string
	index:=strings.Index(greeting,"w")

	split:=strings.Split(greeting," ")

	fmt.Println(split)

Sort ,Search in string

names:=[]string{"foo","boo","goo"}
sort.Strings(names)

fmt.Println(names)

sort.SearchStrings(names,"foo")

numeric

Sort, Seacrch

num:=[]int{98,7,6,5,44,3,3,2,2,1,1,0}
sort.Ints(num)
fmt.Println(num)


index:=sort.SearchInts(num,98)
fmt.Println(index)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages