golang update · • in 2019, go is still popular and a viable option in many domains. • go...
TRANSCRIPT
![Page 1: GOLANG UPDATE · • In 2019, Go is still popular and a viable option in many domains. • Go modules fixes one of the most common points of criticism. • Go 2.0 drafts are definitely](https://reader033.vdocuments.mx/reader033/viewer/2022052613/605389757d67826757783582/html5/thumbnails/1.jpg)
CADEC 2019.01.24 & 2019.01.30 | CALLISTAENTERPRISE.SE
GOLANG UPDATE
ERIK LUPANDER
![Page 2: GOLANG UPDATE · • In 2019, Go is still popular and a viable option in many domains. • Go modules fixes one of the most common points of criticism. • Go 2.0 drafts are definitely](https://reader033.vdocuments.mx/reader033/viewer/2022052613/605389757d67826757783582/html5/thumbnails/2.jpg)
AGENDA
• Where is Go in 2019? • Points of criticism • Go modules • Go 2.0 drafts • Summary
![Page 3: GOLANG UPDATE · • In 2019, Go is still popular and a viable option in many domains. • Go modules fixes one of the most common points of criticism. • Go 2.0 drafts are definitely](https://reader033.vdocuments.mx/reader033/viewer/2022052613/605389757d67826757783582/html5/thumbnails/3.jpg)
GOLANG IN 2019?
![Page 4: GOLANG UPDATE · • In 2019, Go is still popular and a viable option in many domains. • Go modules fixes one of the most common points of criticism. • Go 2.0 drafts are definitely](https://reader033.vdocuments.mx/reader033/viewer/2022052613/605389757d67826757783582/html5/thumbnails/4.jpg)
BACK TO 2017…
![Page 5: GOLANG UPDATE · • In 2019, Go is still popular and a viable option in many domains. • Go modules fixes one of the most common points of criticism. • Go 2.0 drafts are definitely](https://reader033.vdocuments.mx/reader033/viewer/2022052613/605389757d67826757783582/html5/thumbnails/5.jpg)
CADEC 2017 RECAP - WHY GO FOR MICROSERVICES?
• Runtime efficiency • Statically linked binaries • Lightning fast compilation • Cross platform • Pragmatic language favoring simplicity and productivity • Great standard lib and community
![Page 6: GOLANG UPDATE · • In 2019, Go is still popular and a viable option in many domains. • Go modules fixes one of the most common points of criticism. • Go 2.0 drafts are definitely](https://reader033.vdocuments.mx/reader033/viewer/2022052613/605389757d67826757783582/html5/thumbnails/6.jpg)
BACK TO 2017…
• Go had seen a huge increase in popularity • Commonly used in cloud infrastructure software • The advent of microservices seemed a natural fit
![Page 7: GOLANG UPDATE · • In 2019, Go is still popular and a viable option in many domains. • Go modules fixes one of the most common points of criticism. • Go 2.0 drafts are definitely](https://reader033.vdocuments.mx/reader033/viewer/2022052613/605389757d67826757783582/html5/thumbnails/7.jpg)
WHERE IS GO IN 2019?
• Ubiquitous in cloud and systems programming
• Tools, network apps • Microservices, APIs - 1000+ companies listed on the Go
wiki using Go • Much better IDEs • Popularity in rankings stabilized ~#15
![Page 8: GOLANG UPDATE · • In 2019, Go is still popular and a viable option in many domains. • Go modules fixes one of the most common points of criticism. • Go 2.0 drafts are definitely](https://reader033.vdocuments.mx/reader033/viewer/2022052613/605389757d67826757783582/html5/thumbnails/8.jpg)
GO IN THE YEARS AHEAD
• Will Go stay relevant? - Definitely in the cloud infrastructure space - Fierce competition in the microservice / APIs space » JVM ▸ Micronaut, GraalVM
» Rust, NodeJS, PHP 7, .NET Core, … - Go 2.0 on the horizon…
![Page 9: GOLANG UPDATE · • In 2019, Go is still popular and a viable option in many domains. • Go modules fixes one of the most common points of criticism. • Go 2.0 drafts are definitely](https://reader033.vdocuments.mx/reader033/viewer/2022052613/605389757d67826757783582/html5/thumbnails/9.jpg)
POINTS OF
CRITICISM
![Page 10: GOLANG UPDATE · • In 2019, Go is still popular and a viable option in many domains. • Go modules fixes one of the most common points of criticism. • Go 2.0 drafts are definitely](https://reader033.vdocuments.mx/reader033/viewer/2022052613/605389757d67826757783582/html5/thumbnails/10.jpg)
HTTPS://WWW.SLIDESHARE.NET/ARHAN/SOMETHING-ABOUT-GOLANG-53392734
![Page 11: GOLANG UPDATE · • In 2019, Go is still popular and a viable option in many domains. • Go modules fixes one of the most common points of criticism. • Go 2.0 drafts are definitely](https://reader033.vdocuments.mx/reader033/viewer/2022052613/605389757d67826757783582/html5/thumbnails/11.jpg)
HTTPS://GOPHERCISES.COM/
![Page 12: GOLANG UPDATE · • In 2019, Go is still popular and a viable option in many domains. • Go modules fixes one of the most common points of criticism. • Go 2.0 drafts are definitely](https://reader033.vdocuments.mx/reader033/viewer/2022052613/605389757d67826757783582/html5/thumbnails/12.jpg)
POINTS OF CRITICISM
# 1 DEPENDENCY MANAGEMENT
![Page 13: GOLANG UPDATE · • In 2019, Go is still popular and a viable option in many domains. • Go modules fixes one of the most common points of criticism. • Go 2.0 drafts are definitely](https://reader033.vdocuments.mx/reader033/viewer/2022052613/605389757d67826757783582/html5/thumbnails/13.jpg)
DEPENDENCY MANAGEMENT
• Go 1.0 shipped with rudimentary dependency handling - Downloads source from source repositories » Which version? » Transitive dependencies?
• 10+ 3rd-party dependency managers
![Page 14: GOLANG UPDATE · • In 2019, Go is still popular and a viable option in many domains. • Go modules fixes one of the most common points of criticism. • Go 2.0 drafts are definitely](https://reader033.vdocuments.mx/reader033/viewer/2022052613/605389757d67826757783582/html5/thumbnails/14.jpg)
GO MODULES
![Page 15: GOLANG UPDATE · • In 2019, Go is still popular and a viable option in many domains. • Go modules fixes one of the most common points of criticism. • Go 2.0 drafts are definitely](https://reader033.vdocuments.mx/reader033/viewer/2022052613/605389757d67826757783582/html5/thumbnails/15.jpg)
GO MODULES
• Experimental support added in Go 1.11 - Release planned in Go 1.13 - Already 100% functional
• A module is a versioned unit of one or more packages
• Records exact versions of dependencies - Typically git tags » v2.3.4
- Semantic versioning • Reproducible builds
HTTPS://BLOG.SPIRALSCOUT.COM
![Page 16: GOLANG UPDATE · • In 2019, Go is still popular and a viable option in many domains. • Go modules fixes one of the most common points of criticism. • Go 2.0 drafts are definitely](https://reader033.vdocuments.mx/reader033/viewer/2022052613/605389757d67826757783582/html5/thumbnails/16.jpg)
GO MODULES
DEMO TIME!
HTTPS://WWW.DEVIANTART.COM/KIRAEL-ART/ART/GO-LANG-MASCOT-458285682
![Page 17: GOLANG UPDATE · • In 2019, Go is still popular and a viable option in many domains. • Go modules fixes one of the most common points of criticism. • Go 2.0 drafts are definitely](https://reader033.vdocuments.mx/reader033/viewer/2022052613/605389757d67826757783582/html5/thumbnails/17.jpg)
POINTS OF
CRITICISM
CONTINUED…
![Page 18: GOLANG UPDATE · • In 2019, Go is still popular and a viable option in many domains. • Go modules fixes one of the most common points of criticism. • Go 2.0 drafts are definitely](https://reader033.vdocuments.mx/reader033/viewer/2022052613/605389757d67826757783582/html5/thumbnails/18.jpg)
POINTS OF CRITICISM
# 2 ERROR
HANDLING
![Page 19: GOLANG UPDATE · • In 2019, Go is still popular and a viable option in many domains. • Go modules fixes one of the most common points of criticism. • Go 2.0 drafts are definitely](https://reader033.vdocuments.mx/reader033/viewer/2022052613/605389757d67826757783582/html5/thumbnails/19.jpg)
POINTS OF CRITICISM
# 3 (NO)
GENERICS
![Page 20: GOLANG UPDATE · • In 2019, Go is still popular and a viable option in many domains. • Go modules fixes one of the most common points of criticism. • Go 2.0 drafts are definitely](https://reader033.vdocuments.mx/reader033/viewer/2022052613/605389757d67826757783582/html5/thumbnails/20.jpg)
GO 2.0 DRAFTS
![Page 21: GOLANG UPDATE · • In 2019, Go is still popular and a viable option in many domains. • Go modules fixes one of the most common points of criticism. • Go 2.0 drafts are definitely](https://reader033.vdocuments.mx/reader033/viewer/2022052613/605389757d67826757783582/html5/thumbnails/21.jpg)
GO 2.0
• Draft designs for 2.0 released to the community for feedback in sept 2018 - Error handling - Error values - Generics
• Community feedback so far… - The right stuff » Opinions on draft designs vary…
RANDOM STOCK PHOTO
![Page 22: GOLANG UPDATE · • In 2019, Go is still popular and a viable option in many domains. • Go modules fixes one of the most common points of criticism. • Go 2.0 drafts are definitely](https://reader033.vdocuments.mx/reader033/viewer/2022052613/605389757d67826757783582/html5/thumbnails/22.jpg)
POINTS OF CRITICISM
# 2 ERROR
HANDLING
![Page 23: GOLANG UPDATE · • In 2019, Go is still popular and a viable option in many domains. • Go modules fixes one of the most common points of criticism. • Go 2.0 drafts are definitely](https://reader033.vdocuments.mx/reader033/viewer/2022052613/605389757d67826757783582/html5/thumbnails/23.jpg)
ERROR HANDLING - GO 1.X
func DoHttpPost(targetUrl string, payload MyStruct) ([]byte, error) {
parsedUrl, err := url.ParseRequestURI(targetUrl) if err != nil { return handleError(err) }
jsondata, err := json.Marshal(payload) if err != nil { return handleError(err) }
resp, err := http.Post(parsedUrl.String(), "application/json", bytes.NewBuffer(jsondata)) if err != nil { return handleError(err) }
respData, err := ioutil.ReadAll(resp.Body) if err != nil { return handleError(err) } . . .
![Page 24: GOLANG UPDATE · • In 2019, Go is still popular and a viable option in many domains. • Go modules fixes one of the most common points of criticism. • Go 2.0 drafts are definitely](https://reader033.vdocuments.mx/reader033/viewer/2022052613/605389757d67826757783582/html5/thumbnails/24.jpg)
ERROR HANDLING - GO 1.X
func DoHttpPost(targetUrl string, payload MyStruct) ([]byte, error) {
parsedUrl, err := url.ParseRequestURI(targetUrl) if err != nil { return handleError(err) }
jsondata, err := json.Marshal(payload) if err != nil { return handleError(err) }
resp, err := http.Post(parsedUrl.String(), "application/json", bytes.NewBuffer(jsondata)) if err != nil { return handleError(err) }
respData, err := ioutil.ReadAll(resp.Body) if err != nil { return handleError(err) }
![Page 25: GOLANG UPDATE · • In 2019, Go is still popular and a viable option in many domains. • Go modules fixes one of the most common points of criticism. • Go 2.0 drafts are definitely](https://reader033.vdocuments.mx/reader033/viewer/2022052613/605389757d67826757783582/html5/thumbnails/25.jpg)
ERROR HANDLING - GO 2.0 PROPOSAL - WITH EXPLICIT HANDLER
func DoHttpPost(targetUrl string, payload MyStruct) ([]byte, error) {
handle err { return fmt.Errorf(”DoHttpPost failed with %v”, err) }
parsedUrl := check url.ParseRequestURI(targetUrl)
jsondata := check json.Marshal(payload)
resp := check http.Post(parsedUrl.String(), "application/json", bytes.NewBuffer(jsondata))
respData := check ioutil.ReadAll(resp.Body) // Handle response }
![Page 26: GOLANG UPDATE · • In 2019, Go is still popular and a viable option in many domains. • Go modules fixes one of the most common points of criticism. • Go 2.0 drafts are definitely](https://reader033.vdocuments.mx/reader033/viewer/2022052613/605389757d67826757783582/html5/thumbnails/26.jpg)
ERROR HANDLING - GO 2.0 PROPOSAL - WITH IMPLICIT HANDLER
func DoHttpPost(targetUrl string, payload MyStruct) ([]byte, error) {
parsedUrl := check url.ParseRequestURI(targetUrl)
jsondata := check json.Marshal(payload)
resp := check http.Post(parsedUrl.String(), "application/json", bytes.NewBuffer(jsondata))
respData := check ioutil.ReadAll(resp.Body) // Handle response }
![Page 27: GOLANG UPDATE · • In 2019, Go is still popular and a viable option in many domains. • Go modules fixes one of the most common points of criticism. • Go 2.0 drafts are definitely](https://reader033.vdocuments.mx/reader033/viewer/2022052613/605389757d67826757783582/html5/thumbnails/27.jpg)
POINTS OF CRITICISM
# 3 NO
GENERICS
![Page 28: GOLANG UPDATE · • In 2019, Go is still popular and a viable option in many domains. • Go modules fixes one of the most common points of criticism. • Go 2.0 drafts are definitely](https://reader033.vdocuments.mx/reader033/viewer/2022052613/605389757d67826757783582/html5/thumbnails/28.jpg)
RUSS COX GOLANG TEAM
![Page 29: GOLANG UPDATE · • In 2019, Go is still popular and a viable option in many domains. • Go modules fixes one of the most common points of criticism. • Go 2.0 drafts are definitely](https://reader033.vdocuments.mx/reader033/viewer/2022052613/605389757d67826757783582/html5/thumbnails/29.jpg)
”do you want slow programmers,
or
slow compilers and bloated binaries,
or
slow execution times”
RUSS COX ON GENERICS IN 2009
![Page 30: GOLANG UPDATE · • In 2019, Go is still popular and a viable option in many domains. • Go modules fixes one of the most common points of criticism. • Go 2.0 drafts are definitely](https://reader033.vdocuments.mx/reader033/viewer/2022052613/605389757d67826757783582/html5/thumbnails/30.jpg)
”do you want slow programmers,
or
slow compilers and bloated binaries,
or
slow execution times”
RUSS COX ON GENERICS IN 2009
![Page 31: GOLANG UPDATE · • In 2019, Go is still popular and a viable option in many domains. • Go modules fixes one of the most common points of criticism. • Go 2.0 drafts are definitely](https://reader033.vdocuments.mx/reader033/viewer/2022052613/605389757d67826757783582/html5/thumbnails/31.jpg)
NO GENERICS!
![Page 32: GOLANG UPDATE · • In 2019, Go is still popular and a viable option in many domains. • Go modules fixes one of the most common points of criticism. • Go 2.0 drafts are definitely](https://reader033.vdocuments.mx/reader033/viewer/2022052613/605389757d67826757783582/html5/thumbnails/32.jpg)
GO 1.0 CODE SAMPLE
func Filter(items []MyStruct, filterFunc func(MyStruct) bool) []MyStruct { output := make([]MyStruct, 0) for _, item := range items { if filterFunc(item) { output = append(output, item) } } return output }
![Page 33: GOLANG UPDATE · • In 2019, Go is still popular and a viable option in many domains. • Go modules fixes one of the most common points of criticism. • Go 2.0 drafts are definitely](https://reader033.vdocuments.mx/reader033/viewer/2022052613/605389757d67826757783582/html5/thumbnails/33.jpg)
GO 1.0 SAMPLE
func Filter(items []OtherStruct, filterFunc func(OtherStruct) bool) (output []OtherStruct) { output := make([]OtherStruct, 0) for _, item := range items { if filterFunc(item) { output = append(output, item) } } return output }
![Page 34: GOLANG UPDATE · • In 2019, Go is still popular and a viable option in many domains. • Go modules fixes one of the most common points of criticism. • Go 2.0 drafts are definitely](https://reader033.vdocuments.mx/reader033/viewer/2022052613/605389757d67826757783582/html5/thumbnails/34.jpg)
GO 2.0 CODE SAMPLE
func Filter(type T)(items []T, filterFunc func(T) bool) []T { output := make([]T, 0) for _, item := range items { if filterFunc(item) { output = append(output, item) } } return output }
items := []AnyStruct {{”blue”, false}, {”red”, true},}
// Type inferred by compiler output := Filter(items, func(s1 AnyStruct) bool { return s1.IsBlue() })
// Explicit type output := Filter(type AnyStruct)(items, func(s1 AnyStruct) bool { return s1.IsBlue() })
![Page 35: GOLANG UPDATE · • In 2019, Go is still popular and a viable option in many domains. • Go modules fixes one of the most common points of criticism. • Go 2.0 drafts are definitely](https://reader033.vdocuments.mx/reader033/viewer/2022052613/605389757d67826757783582/html5/thumbnails/35.jpg)
GO 2.0 GENERICS - CONTRACTS
• How to enforce that a type T has certain traits that a generic function needs to operate on?
private <T extends Serializable> void serializeToDisk(T item) {
![Page 36: GOLANG UPDATE · • In 2019, Go is still popular and a viable option in many domains. • Go modules fixes one of the most common points of criticism. • Go 2.0 drafts are definitely](https://reader033.vdocuments.mx/reader033/viewer/2022052613/605389757d67826757783582/html5/thumbnails/36.jpg)
GO 2.0 GENERICS - CONTRACTS
• Contracts defines what a generic type T must fulfill - Operators, Fields, Methods, Interface, …
• Type declarations on methods can then specify a contract for a generic type
contract comparable(x T) { x == x }
func Contains(type T comparable)(items []T, element T) bool { for _, item := range items { if item == element { return true } } return false }
contract stringer(x T) { var string = x.String() }
![Page 37: GOLANG UPDATE · • In 2019, Go is still popular and a viable option in many domains. • Go modules fixes one of the most common points of criticism. • Go 2.0 drafts are definitely](https://reader033.vdocuments.mx/reader033/viewer/2022052613/605389757d67826757783582/html5/thumbnails/37.jpg)
SUMMARY
• In 2019, Go is still popular and a viable option in many domains. • Go modules fixes one of the most common points of criticism. • Go 2.0 drafts are definitely promising. - Timeline is largely unknown.
• Go should absolutely be around for many years to come.
![Page 38: GOLANG UPDATE · • In 2019, Go is still popular and a viable option in many domains. • Go modules fixes one of the most common points of criticism. • Go 2.0 drafts are definitely](https://reader033.vdocuments.mx/reader033/viewer/2022052613/605389757d67826757783582/html5/thumbnails/38.jpg)
THANK YOU!
HTTPS://GOPHERIZE.ME/