Learning Golang: Functional Options / Default Configuration Values Pattern
Автор: Mario Carrion
Загружено: 2021-11-05
Просмотров: 4397
Описание:
This is tutorial for a Go pattern, similar to the Builder pattern, that allows defining configuration values, default values and validations called: Functional Options.
This Go Pattern is possible thanks to the power of Go when defining types that happen to be functions combining them with variadic arguments in the "constructor"/initializer function using those values.
I like to use this pattern when the goals are the following:
Expressiveness, we want to clearly indicate the configuration values
Flexibility, we can add new configuration values and our users won't break
Security, we can define validation rules
Defaults, we can define values values
== Relevant Links
Example code: https://github.com/MarioCarrion/video...
Previous Episode: "Learning Golang: Versioning Tools as Dependencies using Go Modules": • Learning Golang: Versioning Tools as Depen...
Playlist "Learning Go": • Learning Go/Golang
Playlist "Software Architecture in Go": • Software Architecture and System Design in...
Playlist "Learning Go/Golang Concurrency Patterns" • Learning Go/Golang Concurrency Patterns
Playlist "Building Microservices in Go": • Building Microservices in Golang/Go
Playlist "GoTools and Packages": • Golang/Go Tools and Packages
Playlist "Testing in Go": • Testing in Golang/Go
== Socials
/ mariocarrion
/ mario.carrion
/ mariocarrion
00:00 Introduction to Golang Function Options / Default Values
04:03 Extract arguments as a new type
06:46 Adding Functional Options
13:33 Adding Validation and errors
17:40 Adding Default Values
19:20 Conclusion
---
Who am I:
Hello👋🏼! I'm Mario, a Hands-on Software Architect and Lead Backend Engineer with more than 16 years of professional experience building all kinds of software including on-premise Industrial Automation Systems, Linux Accessibility Desktop and Browser Components as well as Distributed Advertising Microservices.
Every week I will share with you different topics I've learned while working for small startups and large companies including the processes I've followed over the years for successfully delivering complex enterprise systems from start to end.
Subscribe if you like Software Development, Software Architecture and Systems Design!
Keep it up. Don't give up!
#golang #designpatterns #programming
--- Our affiliate links below
Shop our Amazon favorites → https://www.amazon.com/shop/rubycarrion
Shop my IG feed on my LIKEtoKNOWit (LTK) page → https://www.liketoknow.it/RubyCarrion
Shop Top Deals and Featured Offers at Best Buy → https://bestbuy.7tiv.net/c/2558226/68...
Get a 30 day FREE Trial of Epidemic Sound → https://www.epidemicsound.com/referra...
Try Amazon Prime 30-day FREE Trial → https://amzn.to/3yf9a0f
I love getting Cash Back and think you will too! Join for FREE and get $30 when you spend $30 → https://www.rakuten.com/r/RUBYRA132?e...
--- Our Vlog Channel
/ rubycarrion
Повторяем попытку...
Доступные форматы для скачивания:
Скачать видео
-
Информация по загрузке: