Go (golang) Tutorials - Custom Packages and Functions

1720
6
25
13.03.2018
Ambasoft Java

Ambasoft Java

35268
298
38
08.03.2018
Описание видео:

#golang #go #packages Custom Packages and Functions - A. Blank identifier - _ "underscore" B. Godoc - Utility to get package documentation about all the go packages C. Returning values from functions - User defined functions D. Custom packages Note:- Function names starts with lowercase alphabets will not be exported to use outside from a go program Function names started with uppercase letters are only can be used outside the go program or package 1. Set up GOPATH to the current working directory/ root of the package 2. Inside GOPATH directory create src/packagename ex:- GOPATH/src/hello - Hello is the name of the package 3. Create Package Hello (not a command) 4. Switch over to the GOPATH directory 5. Create a go program to import and use the custom package hello Source Code - blankdemo.go package main import ("fmt" _ "strings" ) func main(){ fmt.Println("Blank demo") } funcdemo.go - package main import "fmt" func main(){ show() //Call Function Show display("Calling display with argument") result:=add(10,20) fmt.Printf("The sum is %d\n",result) } func show(){ fmt.Println("Inside Show Function") } func display(message string){ fmt.Println(message) } func add(first int,second int)(int){ //Return values from the function sum:=first+second return sum } mathematics.go (create it inside GOPATH/src/mathematics/) - package mathematics func Add(a int,b int)(int){ return a+b } func Sub(a int,b int)(int){ return a-b } func Mul(a int,b int)(int){ return a*b } func Div(a int,b int)(int){ return a/b } calc.go (create it inside GOPATH) - package main import ("mathematics" "fmt" ) func main(){ a:=20 b:=10 fmt.Printf("The sum of %d and %d is %d \n",a,b,mathematics.Add(a,b)) fmt.Printf("The difference of %d and %d is %d\n",a,b,mathematics.Sub(a,b)) fmt.Printf("The product of %d and %d is %d\n",a,b,mathematics.Mul(a,b)) fmt.Printf("The division of %d and %d is %d\n",a,b,mathematics.Div(a,b)) }

Кадры из видео
Go (golang) Tutorials - Custom Packages and Functions
Go (golang) Tutorials - Custom Packages and Functions
Go (golang) Tutorials - Custom Packages and Functions
Go (golang) Tutorials - Custom Packages and Functions
Тэги из видео
Комментарии пользователей:
Abhaykant Nirala
2020-11-12 10:44:15

You did a great job. :)

Krishna G
2020-08-09 14:12:41

You did nice job.. Thanks

Что ищут прямо сейчас
apollo solo review iphone vs carro overlap shrink machine brasileirão eddie pepperrell Isslam Looping GIFs phone hacking 纪实 mages guild GERD liquid manure ch341a CHINESE CUISINE 명작 big engine swap sefo sanki ben amk Daily Busking campioni del mondo
Похожие видео
05.04.2018
Go (golang) Tutorials - Command Line Arguments, File I/O

Go (golang) Tutorials - Command Line Arguments, File I/O

19.02.2021
Go (golang) Advanced Tutorials - Mutex and Waitgroup, Console Input

Go (golang) Advanced Tutorials - Mutex and Waitgroup, Console Input

13.04.2018
Go (golang) Tutorials - Closing channels and Iteration

Go (golang) Tutorials - Closing channels and Iteration

29.07.2015
IO, buffers, readers, writers

IO, buffers, readers, writers

05.01.2020
Introduction to microservices (Ep. 1)

Introduction to microservices (Ep. 1)

15.04.2018
Go (golang) Tutorials - Buffered Channels

Go (golang) Tutorials - Buffered Channels

26.09.2018
All About Go

All About Go

24.05.2020
Golang Tutorial #21 - Struct Methods

Golang Tutorial #21 - Struct Methods

07.11.2018
Journey from OO language to Golang - Sergey Kibish @DevFest Switzerland 2018

Journey from OO language to Golang - Sergey Kibish @DevFest Switzerland 2018

18.02.2021
Go (golang) Advanced Tutorials - File I/O using ioutil package , Temporary File, Temporary Directory

Go (golang) Advanced Tutorials - File I/O using ioutil package , Temporary File, Temporary Directory

23.12.2020
An Introduction to Targeting Web Assembly (WASM) with Golang

An Introduction to Targeting Web Assembly (WASM) with Golang

06.04.2018
Go (golang) Tutorials - File I/O using OS Package

Go (golang) Tutorials - File I/O using OS Package

04.03.2017
Introduction to Go, part 7: Maps and Structs

Introduction to Go, part 7: Maps and Structs

06.03.2020
Structs in golang

Structs in golang

15.11.2017
Understanding INTERFACES in GOLANG

Understanding INTERFACES in GOLANG

07.04.2018
Go (golang) Tutorials - Buffered File I/O

Go (golang) Tutorials - Buffered File I/O

28.10.2020
Create A Docker Container For Go (golang) Code In UNDER Ten Minutes [Getting Started)

Create A Docker Container For Go (golang) Code In UNDER Ten Minutes [Getting Started)