Load a JSON Configuration from File in a Golang Application

preview_player
Показать описание
Learn how to load a JSON configuration file into a native Go structure in a Golang application.

Рекомендации по теме
Комментарии
Автор

Life saver and relatively straightforward, missing the detail on the encoding/json, which has been mentioned previously but otherwise worked fine for me.

VicoSurge
Автор

You said that @ 5:00 that config was nil but it is not. Variables in golang are defaulted to their zero values when not defined.

TarikGuney
Автор

Another tip would be instead of using the filename as a parameter, try to pass an interface. With this approach this get easier to unittest. =]

miguelitoo
Автор

Hi. What are your font and color scheme please ? Thanks.

webi
Автор

Why do I have to put the same value that I have set in my struct above the struct. -> i.e: Host string `json:"host"`

tadeubernacchi
Автор

line 19, you say config return is nil, but in reality is a zero value of config type.

LuisFernandoGaido
Автор

Actually you are forgotten to add an import called "encoding/json" before using it! The rest was great!

simonvanwingerden
Автор

In Atom, what packages do you have enabled for Go development?

NoSQLKnowHow
Автор

Tnx, doesn't work for me but great vid! Helped.

Oswee
welcome to shbcf.ru