SlideShare a Scribd company logo
1 of 24
Download to read offline
Learning Go for Perl
Programmers
Fred Moyer
SF Perl Mongers, 06082016
The Go Programming Language
Developed at Google circa 2007
Goroutines (threads)
Channels (queues)
One way to format code (gofmt)
Hello SF.pm!
package main
import "fmt"
func main() {
fmt.Println("Hello, サンフランシスコのPerlモンガー")
}
Hash || Object => Struct
type Person struct {
id int // lowercase fields are not exported
email string // note no commas after variable type
Name string
HeightCentimeters float32 // camelCase convention
IsAlive bool // true or false, defaults to false
}
Hash || Object => Struct
var famousActor = Person{
id: 1,
email: "jeff@goldblum.org",
Name: "Jeff Goldblum", // no single quotes
HeightCentimeters: 193.5,
IsAlive: true,
}
Hash || Object => Struct
// we all knew this day would come
// perhaps in Independence Day: Resurgence?
// use the dot notation to make it happen
famousActor.IsAlive = false
Array => Slice
var tallActors []string
tallActors = append(tallActors, “Dolph Lundgren”)
tallActors[0] = “Richard Kiel”
tallActors[1] = “Chevy Chase” // error: index out of range
tallActors = append(tallActors, “Vince Vaughn”)
tallActorsCopy := make([]string, len(tallActors))
copy(tallActorsCopy, tallActors)
Array => Array
// not used nearly as much as slices
var tenIntegers [10]int
fiveIntegers := [5]int{1,2,3,4,5}
lastThreeIntegers := fiveIntegers[2:] // outputs 3,4,5
firstTwoIntegers := fiveIntegers[:2] // outputs 1,2
Hash => Map
countries := make(map[string]int)
countries[“Canada”] = 1
countries[“US”] = 2
canadaId = countries[“Canada”] // 1
delete(countries, “US”)
countries := map[string]int{“Canada”: 1, “US”: 2}
countryId, exists := countries[“Atlantis”] // exists == nil
Loops
for i:= 0; i < 10; i++ {
fmt.Printf(“We’re going to 11”, i+1)
}
for i, actor := range []string{“Van Dam”, “Liam Neeson”} {
fmt.Printf(“#%d is %v”, i, actor) // %v default format
}
for _, actor := ... // _ ignores the loop iterator value
$@ => err
bytesRead, err := w.Write([]byte{“data written to client”})
if err != nil {
log.WithField("err", err).Error("write to client failed")
}
var err error // built in error type
err.Error() // format error as a string
use => import
import (
"database/sql"
"encoding/json"
"flag"
"fmt"
)
sub foo => func foo (bar string, boo int)
func httpEndpoint(world string) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r
*http.Request) {
bytesRead, _ := w.Write([]byte(
fmt.Sprintf(“Hello %v!”, world)))
return
}
}
t/test.t => main_test.go
main.go # file containing your code, ‘go run main.go’
main_test.go # unit test for main.go
go test # runs main_test.go, executes all tests
func TestSomething(t *testing.T) {
// do some stuff
if err != nil { t.Errorf("test failed %v", err) }
}
perldoc => godoc
$ godoc fmt
use 'godoc cmd/fmt' for documentation on the fmt command
PACKAGE DOCUMENTATION
package fmt
import "fmt"
...
perldoc => godoc
$ godoc fmt Sprintf
use 'godoc cmd/fmt' for documentation on the fmt command
func Sprintf(format string, a ...interface{}) string
Sprintf formats according to a format specifier and
returns the
resulting string.
CPAN => https://golang.org/pkg/
cpanminus => go get
go get github.com/quipo/statsd
$ ls gocode/src/github.com/quipo/statsd/
LICENSE bufferedclient_test.go event
README.md client.go interface.go
bufferedclient.go client_test.go noopclient.go
PERL5LIB => GOPATH
$ echo $GOPATH
/Users/phred/gocode
$ ls gocode/
bin pkg src
$ ls gocode/src/
github.com glenda golang.org
? => go build
$ pwd
~/gocode/src/myorg/myapp
$ ls
main.go main_test.go
$ go build; ls
main.go main_test.go myapp
./myapp # binary executable you can relocate to same arch
queues => channels
c := make(chan string) // queue for string data type
hello := “Hello SF.pm”
c <- hello
// ...
fmt.Println(<-c) // prints “Hello.SF.pm”
bufferedChannel := make(chan string, 2) // buffers 2 strings
// channels are first class citizens of Go
threads => goroutines
hello := “Hello SF.pm”
go myFunc(hello)
func myFunc(myString string) {
fmt.Println(myString)
}
// spawns an asynchronous thread which executes a function
// goroutines are first class citizens of Go
Tour of Golang web places
https://golang.org/
https://tour.golang.org/welcome/1
https://golang.org/pkg/
https://groups.google.com/forum/#!forum/golang-nuts
Questions?

More Related Content

What's hot

Introduction to Programming in Go
Introduction to Programming in GoIntroduction to Programming in Go
Introduction to Programming in GoAmr Hassan
 
From 0 to mine sweeper in pyside
From 0 to mine sweeper in pysideFrom 0 to mine sweeper in pyside
From 0 to mine sweeper in pysideDinesh Manajipet
 
Golang iran - tutorial go programming language - Preliminary
Golang iran - tutorial  go programming language - PreliminaryGolang iran - tutorial  go programming language - Preliminary
Golang iran - tutorial go programming language - Preliminarygo-lang
 
Happy Go Programming
Happy Go ProgrammingHappy Go Programming
Happy Go ProgrammingLin Yo-An
 
Vim Script Programming
Vim Script ProgrammingVim Script Programming
Vim Script ProgrammingLin Yo-An
 
Getting groovy (ODP)
Getting groovy (ODP)Getting groovy (ODP)
Getting groovy (ODP)Nick Dixon
 
How to develop a rich terminal UI application
How to develop a rich terminal UI applicationHow to develop a rich terminal UI application
How to develop a rich terminal UI applicationMasashi Shibata
 
Golangにおける端末制御 リッチなターミナルUIの実現方法
Golangにおける端末制御 リッチなターミナルUIの実現方法Golangにおける端末制御 リッチなターミナルUIの実現方法
Golangにおける端末制御 リッチなターミナルUIの実現方法Masashi Shibata
 
Unix And C
Unix And CUnix And C
Unix And CDr.Ravi
 
An Intro to Python in 30 minutes
An Intro to Python in 30 minutesAn Intro to Python in 30 minutes
An Intro to Python in 30 minutesSumit Raj
 
Getting Started with Go
Getting Started with GoGetting Started with Go
Getting Started with GoSteven Francia
 
Painless Data Storage with MongoDB & Go
Painless Data Storage with MongoDB & Go Painless Data Storage with MongoDB & Go
Painless Data Storage with MongoDB & Go Steven Francia
 
C: A Humbling Language
C: A Humbling LanguageC: A Humbling Language
C: A Humbling Languageguestaa63aa
 
PyCon 2013 : Scripting to PyPi to GitHub and More
PyCon 2013 : Scripting to PyPi to GitHub and MorePyCon 2013 : Scripting to PyPi to GitHub and More
PyCon 2013 : Scripting to PyPi to GitHub and MoreMatt Harrison
 
Coding in GO - GDG SL - NSBM
Coding in GO - GDG SL - NSBMCoding in GO - GDG SL - NSBM
Coding in GO - GDG SL - NSBMRaveen Perera
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to pythonAhmed Salama
 

What's hot (20)

Introduction to Programming in Go
Introduction to Programming in GoIntroduction to Programming in Go
Introduction to Programming in Go
 
From 0 to mine sweeper in pyside
From 0 to mine sweeper in pysideFrom 0 to mine sweeper in pyside
From 0 to mine sweeper in pyside
 
Golang iran - tutorial go programming language - Preliminary
Golang iran - tutorial  go programming language - PreliminaryGolang iran - tutorial  go programming language - Preliminary
Golang iran - tutorial go programming language - Preliminary
 
Happy Go Programming
Happy Go ProgrammingHappy Go Programming
Happy Go Programming
 
Vim Script Programming
Vim Script ProgrammingVim Script Programming
Vim Script Programming
 
Getting groovy (ODP)
Getting groovy (ODP)Getting groovy (ODP)
Getting groovy (ODP)
 
How to develop a rich terminal UI application
How to develop a rich terminal UI applicationHow to develop a rich terminal UI application
How to develop a rich terminal UI application
 
Golangにおける端末制御 リッチなターミナルUIの実現方法
Golangにおける端末制御 リッチなターミナルUIの実現方法Golangにおける端末制御 リッチなターミナルUIの実現方法
Golangにおける端末制御 リッチなターミナルUIの実現方法
 
Unix And C
Unix And CUnix And C
Unix And C
 
An Intro to Python in 30 minutes
An Intro to Python in 30 minutesAn Intro to Python in 30 minutes
An Intro to Python in 30 minutes
 
Getting Started with Go
Getting Started with GoGetting Started with Go
Getting Started with Go
 
Defer, Panic, Recover
Defer, Panic, RecoverDefer, Panic, Recover
Defer, Panic, Recover
 
Painless Data Storage with MongoDB & Go
Painless Data Storage with MongoDB & Go Painless Data Storage with MongoDB & Go
Painless Data Storage with MongoDB & Go
 
Golang
GolangGolang
Golang
 
C: A Humbling Language
C: A Humbling LanguageC: A Humbling Language
C: A Humbling Language
 
Linux basic1&amp;2
Linux basic1&amp;2Linux basic1&amp;2
Linux basic1&amp;2
 
Отладка в GDB
Отладка в GDBОтладка в GDB
Отладка в GDB
 
PyCon 2013 : Scripting to PyPi to GitHub and More
PyCon 2013 : Scripting to PyPi to GitHub and MorePyCon 2013 : Scripting to PyPi to GitHub and More
PyCon 2013 : Scripting to PyPi to GitHub and More
 
Coding in GO - GDG SL - NSBM
Coding in GO - GDG SL - NSBMCoding in GO - GDG SL - NSBM
Coding in GO - GDG SL - NSBM
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 

Viewers also liked

GO programming language
GO programming languageGO programming language
GO programming languagetung vu
 
Как устроен поиск (Андрей Аксёнов)
Как устроен поиск (Андрей Аксёнов)Как устроен поиск (Андрей Аксёнов)
Как устроен поиск (Андрей Аксёнов)Ontico
 
Анатомия веб сервиса (HighLoad-2014)
Анатомия веб сервиса (HighLoad-2014)Анатомия веб сервиса (HighLoad-2014)
Анатомия веб сервиса (HighLoad-2014)Andrey Smirnov
 
Консольные приложения на Go
Консольные приложения на GoКонсольные приложения на Go
Консольные приложения на GoAndrey Smirnov
 
Клиентские приложения под нагрузкой (HighLoad 2014)
Клиентские приложения под нагрузкой (HighLoad 2014)Клиентские приложения под нагрузкой (HighLoad 2014)
Клиентские приложения под нагрузкой (HighLoad 2014)Andrey Smirnov
 
Fuzzing: The New Unit Testing
Fuzzing: The New Unit TestingFuzzing: The New Unit Testing
Fuzzing: The New Unit TestingDmitry Vyukov
 
Develop Android app using Golang
Develop Android app using GolangDevelop Android app using Golang
Develop Android app using GolangSeongJae Park
 

Viewers also liked (7)

GO programming language
GO programming languageGO programming language
GO programming language
 
Как устроен поиск (Андрей Аксёнов)
Как устроен поиск (Андрей Аксёнов)Как устроен поиск (Андрей Аксёнов)
Как устроен поиск (Андрей Аксёнов)
 
Анатомия веб сервиса (HighLoad-2014)
Анатомия веб сервиса (HighLoad-2014)Анатомия веб сервиса (HighLoad-2014)
Анатомия веб сервиса (HighLoad-2014)
 
Консольные приложения на Go
Консольные приложения на GoКонсольные приложения на Go
Консольные приложения на Go
 
Клиентские приложения под нагрузкой (HighLoad 2014)
Клиентские приложения под нагрузкой (HighLoad 2014)Клиентские приложения под нагрузкой (HighLoad 2014)
Клиентские приложения под нагрузкой (HighLoad 2014)
 
Fuzzing: The New Unit Testing
Fuzzing: The New Unit TestingFuzzing: The New Unit Testing
Fuzzing: The New Unit Testing
 
Develop Android app using Golang
Develop Android app using GolangDevelop Android app using Golang
Develop Android app using Golang
 

Similar to Learning go for perl programmers

Golang basics for Java developers - Part 1
Golang basics for Java developers - Part 1Golang basics for Java developers - Part 1
Golang basics for Java developers - Part 1Robert Stern
 
Go serving: Building server app with go
Go serving: Building server app with goGo serving: Building server app with go
Go serving: Building server app with goHean Hong Leong
 
Fantom on the JVM Devoxx09 BOF
Fantom on the JVM Devoxx09 BOFFantom on the JVM Devoxx09 BOF
Fantom on the JVM Devoxx09 BOFDror Bereznitsky
 
Go for Rubyists
Go for RubyistsGo for Rubyists
Go for Rubyiststchandy
 
2007 09 10 Fzi Training Groovy Grails V Ws
2007 09 10 Fzi Training Groovy Grails V Ws2007 09 10 Fzi Training Groovy Grails V Ws
2007 09 10 Fzi Training Groovy Grails V Wsloffenauer
 
golang_getting_started.pptx
golang_getting_started.pptxgolang_getting_started.pptx
golang_getting_started.pptxGuy Komari
 
OSCON2014 : Quick Introduction to System Tools Programming with Go
OSCON2014 : Quick Introduction to System Tools Programming with GoOSCON2014 : Quick Introduction to System Tools Programming with Go
OSCON2014 : Quick Introduction to System Tools Programming with GoChris McEniry
 
Unit 8
Unit 8Unit 8
Unit 8siddr
 
Beauty and Power of Go
Beauty and Power of GoBeauty and Power of Go
Beauty and Power of GoFrank Müller
 
Formatting ForThe Masses
Formatting ForThe MassesFormatting ForThe Masses
Formatting ForThe MassesHolger Schill
 
Building a friendly .NET SDK to connect to Space
Building a friendly .NET SDK to connect to SpaceBuilding a friendly .NET SDK to connect to Space
Building a friendly .NET SDK to connect to SpaceMaarten Balliauw
 
Geeks Anonymes - Le langage Go
Geeks Anonymes - Le langage GoGeeks Anonymes - Le langage Go
Geeks Anonymes - Le langage GoGeeks Anonymes
 
Fantom - Programming Language for JVM, CLR, and Javascript
Fantom - Programming Language for JVM, CLR, and JavascriptFantom - Programming Language for JVM, CLR, and Javascript
Fantom - Programming Language for JVM, CLR, and JavascriptKamil Toman
 
NodeJs
NodeJsNodeJs
NodeJsdizabl
 

Similar to Learning go for perl programmers (20)

Golang basics for Java developers - Part 1
Golang basics for Java developers - Part 1Golang basics for Java developers - Part 1
Golang basics for Java developers - Part 1
 
Let's Go-lang
Let's Go-langLet's Go-lang
Let's Go-lang
 
Go serving: Building server app with go
Go serving: Building server app with goGo serving: Building server app with go
Go serving: Building server app with go
 
Golang workshop
Golang workshopGolang workshop
Golang workshop
 
Fantom on the JVM Devoxx09 BOF
Fantom on the JVM Devoxx09 BOFFantom on the JVM Devoxx09 BOF
Fantom on the JVM Devoxx09 BOF
 
Go for Rubyists
Go for RubyistsGo for Rubyists
Go for Rubyists
 
Introduction to Go
Introduction to GoIntroduction to Go
Introduction to Go
 
2007 09 10 Fzi Training Groovy Grails V Ws
2007 09 10 Fzi Training Groovy Grails V Ws2007 09 10 Fzi Training Groovy Grails V Ws
2007 09 10 Fzi Training Groovy Grails V Ws
 
Txjs
TxjsTxjs
Txjs
 
golang_getting_started.pptx
golang_getting_started.pptxgolang_getting_started.pptx
golang_getting_started.pptx
 
OSCON2014 : Quick Introduction to System Tools Programming with Go
OSCON2014 : Quick Introduction to System Tools Programming with GoOSCON2014 : Quick Introduction to System Tools Programming with Go
OSCON2014 : Quick Introduction to System Tools Programming with Go
 
Unit 8
Unit 8Unit 8
Unit 8
 
A Tour of Go - Workshop
A Tour of Go - WorkshopA Tour of Go - Workshop
A Tour of Go - Workshop
 
Sbaw091006
Sbaw091006Sbaw091006
Sbaw091006
 
Beauty and Power of Go
Beauty and Power of GoBeauty and Power of Go
Beauty and Power of Go
 
Formatting ForThe Masses
Formatting ForThe MassesFormatting ForThe Masses
Formatting ForThe Masses
 
Building a friendly .NET SDK to connect to Space
Building a friendly .NET SDK to connect to SpaceBuilding a friendly .NET SDK to connect to Space
Building a friendly .NET SDK to connect to Space
 
Geeks Anonymes - Le langage Go
Geeks Anonymes - Le langage GoGeeks Anonymes - Le langage Go
Geeks Anonymes - Le langage Go
 
Fantom - Programming Language for JVM, CLR, and Javascript
Fantom - Programming Language for JVM, CLR, and JavascriptFantom - Programming Language for JVM, CLR, and Javascript
Fantom - Programming Language for JVM, CLR, and Javascript
 
NodeJs
NodeJsNodeJs
NodeJs
 

More from Fred Moyer

Reliable observability at scale: Error Budgets for 1,000+
Reliable observability at scale: Error Budgets for 1,000+Reliable observability at scale: Error Budgets for 1,000+
Reliable observability at scale: Error Budgets for 1,000+Fred Moyer
 
Practical service level objectives with error budgeting
Practical service level objectives with error budgetingPractical service level objectives with error budgeting
Practical service level objectives with error budgetingFred Moyer
 
SREcon americas 2019 - Latency SLOs Done Right
SREcon americas 2019 - Latency SLOs Done RightSREcon americas 2019 - Latency SLOs Done Right
SREcon americas 2019 - Latency SLOs Done RightFred Moyer
 
Scale17x - Latency SLOs Done Right
Scale17x - Latency SLOs Done RightScale17x - Latency SLOs Done Right
Scale17x - Latency SLOs Done RightFred Moyer
 
Latency SLOs Done Right
Latency SLOs Done RightLatency SLOs Done Right
Latency SLOs Done RightFred Moyer
 
Latency SLOs done right
Latency SLOs done rightLatency SLOs done right
Latency SLOs done rightFred Moyer
 
Comprehensive Container Based Service Monitoring with Kubernetes and Istio
Comprehensive Container Based Service Monitoring with Kubernetes and IstioComprehensive Container Based Service Monitoring with Kubernetes and Istio
Comprehensive Container Based Service Monitoring with Kubernetes and IstioFred Moyer
 
Comprehensive container based service monitoring with kubernetes and istio
Comprehensive container based service monitoring with kubernetes and istioComprehensive container based service monitoring with kubernetes and istio
Comprehensive container based service monitoring with kubernetes and istioFred Moyer
 
Effective management of high volume numeric data with histograms
Effective management of high volume numeric data with histogramsEffective management of high volume numeric data with histograms
Effective management of high volume numeric data with histogramsFred Moyer
 
Statistics for dummies
Statistics for dummiesStatistics for dummies
Statistics for dummiesFred Moyer
 
GrafanaCon EU 2018
GrafanaCon EU 2018GrafanaCon EU 2018
GrafanaCon EU 2018Fred Moyer
 
Fredmoyer postgresopen 2017
Fredmoyer postgresopen 2017Fredmoyer postgresopen 2017
Fredmoyer postgresopen 2017Fred Moyer
 
Better service monitoring through histograms sv perl 09012016
Better service monitoring through histograms sv perl 09012016Better service monitoring through histograms sv perl 09012016
Better service monitoring through histograms sv perl 09012016Fred Moyer
 
Better service monitoring through histograms
Better service monitoring through histogramsBetter service monitoring through histograms
Better service monitoring through histogramsFred Moyer
 
The Breakup - Logically Sharding a Growing PostgreSQL Database
The Breakup - Logically Sharding a Growing PostgreSQL DatabaseThe Breakup - Logically Sharding a Growing PostgreSQL Database
The Breakup - Logically Sharding a Growing PostgreSQL DatabaseFred Moyer
 
Surge 2012 fred_moyer_lightning
Surge 2012 fred_moyer_lightningSurge 2012 fred_moyer_lightning
Surge 2012 fred_moyer_lightningFred Moyer
 
Apache Dispatch
Apache DispatchApache Dispatch
Apache DispatchFred Moyer
 
Ball Of Mud Yapc 2008
Ball Of Mud Yapc 2008Ball Of Mud Yapc 2008
Ball Of Mud Yapc 2008Fred Moyer
 
Data::FormValidator Simplified
Data::FormValidator SimplifiedData::FormValidator Simplified
Data::FormValidator SimplifiedFred Moyer
 

More from Fred Moyer (20)

Reliable observability at scale: Error Budgets for 1,000+
Reliable observability at scale: Error Budgets for 1,000+Reliable observability at scale: Error Budgets for 1,000+
Reliable observability at scale: Error Budgets for 1,000+
 
Practical service level objectives with error budgeting
Practical service level objectives with error budgetingPractical service level objectives with error budgeting
Practical service level objectives with error budgeting
 
SREcon americas 2019 - Latency SLOs Done Right
SREcon americas 2019 - Latency SLOs Done RightSREcon americas 2019 - Latency SLOs Done Right
SREcon americas 2019 - Latency SLOs Done Right
 
Scale17x - Latency SLOs Done Right
Scale17x - Latency SLOs Done RightScale17x - Latency SLOs Done Right
Scale17x - Latency SLOs Done Right
 
Latency SLOs Done Right
Latency SLOs Done RightLatency SLOs Done Right
Latency SLOs Done Right
 
Latency SLOs done right
Latency SLOs done rightLatency SLOs done right
Latency SLOs done right
 
Comprehensive Container Based Service Monitoring with Kubernetes and Istio
Comprehensive Container Based Service Monitoring with Kubernetes and IstioComprehensive Container Based Service Monitoring with Kubernetes and Istio
Comprehensive Container Based Service Monitoring with Kubernetes and Istio
 
Comprehensive container based service monitoring with kubernetes and istio
Comprehensive container based service monitoring with kubernetes and istioComprehensive container based service monitoring with kubernetes and istio
Comprehensive container based service monitoring with kubernetes and istio
 
Effective management of high volume numeric data with histograms
Effective management of high volume numeric data with histogramsEffective management of high volume numeric data with histograms
Effective management of high volume numeric data with histograms
 
Statistics for dummies
Statistics for dummiesStatistics for dummies
Statistics for dummies
 
GrafanaCon EU 2018
GrafanaCon EU 2018GrafanaCon EU 2018
GrafanaCon EU 2018
 
Fredmoyer postgresopen 2017
Fredmoyer postgresopen 2017Fredmoyer postgresopen 2017
Fredmoyer postgresopen 2017
 
Better service monitoring through histograms sv perl 09012016
Better service monitoring through histograms sv perl 09012016Better service monitoring through histograms sv perl 09012016
Better service monitoring through histograms sv perl 09012016
 
Better service monitoring through histograms
Better service monitoring through histogramsBetter service monitoring through histograms
Better service monitoring through histograms
 
The Breakup - Logically Sharding a Growing PostgreSQL Database
The Breakup - Logically Sharding a Growing PostgreSQL DatabaseThe Breakup - Logically Sharding a Growing PostgreSQL Database
The Breakup - Logically Sharding a Growing PostgreSQL Database
 
Surge 2012 fred_moyer_lightning
Surge 2012 fred_moyer_lightningSurge 2012 fred_moyer_lightning
Surge 2012 fred_moyer_lightning
 
Qpsmtpd
QpsmtpdQpsmtpd
Qpsmtpd
 
Apache Dispatch
Apache DispatchApache Dispatch
Apache Dispatch
 
Ball Of Mud Yapc 2008
Ball Of Mud Yapc 2008Ball Of Mud Yapc 2008
Ball Of Mud Yapc 2008
 
Data::FormValidator Simplified
Data::FormValidator SimplifiedData::FormValidator Simplified
Data::FormValidator Simplified
 

Recently uploaded

Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceanilsa9823
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 

Recently uploaded (20)

CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 

Learning go for perl programmers

  • 1. Learning Go for Perl Programmers Fred Moyer SF Perl Mongers, 06082016
  • 2. The Go Programming Language Developed at Google circa 2007 Goroutines (threads) Channels (queues) One way to format code (gofmt)
  • 3. Hello SF.pm! package main import "fmt" func main() { fmt.Println("Hello, サンフランシスコのPerlモンガー") }
  • 4. Hash || Object => Struct type Person struct { id int // lowercase fields are not exported email string // note no commas after variable type Name string HeightCentimeters float32 // camelCase convention IsAlive bool // true or false, defaults to false }
  • 5. Hash || Object => Struct var famousActor = Person{ id: 1, email: "jeff@goldblum.org", Name: "Jeff Goldblum", // no single quotes HeightCentimeters: 193.5, IsAlive: true, }
  • 6. Hash || Object => Struct // we all knew this day would come // perhaps in Independence Day: Resurgence? // use the dot notation to make it happen famousActor.IsAlive = false
  • 7. Array => Slice var tallActors []string tallActors = append(tallActors, “Dolph Lundgren”) tallActors[0] = “Richard Kiel” tallActors[1] = “Chevy Chase” // error: index out of range tallActors = append(tallActors, “Vince Vaughn”) tallActorsCopy := make([]string, len(tallActors)) copy(tallActorsCopy, tallActors)
  • 8. Array => Array // not used nearly as much as slices var tenIntegers [10]int fiveIntegers := [5]int{1,2,3,4,5} lastThreeIntegers := fiveIntegers[2:] // outputs 3,4,5 firstTwoIntegers := fiveIntegers[:2] // outputs 1,2
  • 9. Hash => Map countries := make(map[string]int) countries[“Canada”] = 1 countries[“US”] = 2 canadaId = countries[“Canada”] // 1 delete(countries, “US”) countries := map[string]int{“Canada”: 1, “US”: 2} countryId, exists := countries[“Atlantis”] // exists == nil
  • 10. Loops for i:= 0; i < 10; i++ { fmt.Printf(“We’re going to 11”, i+1) } for i, actor := range []string{“Van Dam”, “Liam Neeson”} { fmt.Printf(“#%d is %v”, i, actor) // %v default format } for _, actor := ... // _ ignores the loop iterator value
  • 11. $@ => err bytesRead, err := w.Write([]byte{“data written to client”}) if err != nil { log.WithField("err", err).Error("write to client failed") } var err error // built in error type err.Error() // format error as a string
  • 12. use => import import ( "database/sql" "encoding/json" "flag" "fmt" )
  • 13. sub foo => func foo (bar string, boo int) func httpEndpoint(world string) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { bytesRead, _ := w.Write([]byte( fmt.Sprintf(“Hello %v!”, world))) return } }
  • 14. t/test.t => main_test.go main.go # file containing your code, ‘go run main.go’ main_test.go # unit test for main.go go test # runs main_test.go, executes all tests func TestSomething(t *testing.T) { // do some stuff if err != nil { t.Errorf("test failed %v", err) } }
  • 15. perldoc => godoc $ godoc fmt use 'godoc cmd/fmt' for documentation on the fmt command PACKAGE DOCUMENTATION package fmt import "fmt" ...
  • 16. perldoc => godoc $ godoc fmt Sprintf use 'godoc cmd/fmt' for documentation on the fmt command func Sprintf(format string, a ...interface{}) string Sprintf formats according to a format specifier and returns the resulting string.
  • 18. cpanminus => go get go get github.com/quipo/statsd $ ls gocode/src/github.com/quipo/statsd/ LICENSE bufferedclient_test.go event README.md client.go interface.go bufferedclient.go client_test.go noopclient.go
  • 19. PERL5LIB => GOPATH $ echo $GOPATH /Users/phred/gocode $ ls gocode/ bin pkg src $ ls gocode/src/ github.com glenda golang.org
  • 20. ? => go build $ pwd ~/gocode/src/myorg/myapp $ ls main.go main_test.go $ go build; ls main.go main_test.go myapp ./myapp # binary executable you can relocate to same arch
  • 21. queues => channels c := make(chan string) // queue for string data type hello := “Hello SF.pm” c <- hello // ... fmt.Println(<-c) // prints “Hello.SF.pm” bufferedChannel := make(chan string, 2) // buffers 2 strings // channels are first class citizens of Go
  • 22. threads => goroutines hello := “Hello SF.pm” go myFunc(hello) func myFunc(myString string) { fmt.Println(myString) } // spawns an asynchronous thread which executes a function // goroutines are first class citizens of Go
  • 23. Tour of Golang web places https://golang.org/ https://tour.golang.org/welcome/1 https://golang.org/pkg/ https://groups.google.com/forum/#!forum/golang-nuts