配置文件类型用法

Usually I saw config file in many examples out there are in .env or .json file.

What if I decide to use .go file instead , is it uncommon, how it should be done?

I was thinking since .env file is static, if I want to put config like this

var currentDate = time.Now()
var currentDateFormat = currentDate.Format("2006-01-02")
var logPath = dir + "/log/" + currentDateFormat + ".log"

It can't be done in .env file so should I just keep the above config within function somewhere and stick with .env file?

What if I decide to use .go file instead

Then it is no longer a config file (static content), but a source file, which needs to be compiled and part of your exe (runtime content).

It then could be part of an init() function for instance.
Or part of a config package source, in charge of loading your config as well as initializing the variables in your question.