UnnoTed / fileb0x

a better customizable tool to embed files in go; also update embedded files remotely without restarting the server
MIT License
634 stars 53 forks source link

Added Init config variable. #46

Open scudette opened 5 years ago

scudette commented 5 years ago

When the config file specifies the Init option, the initialization function will be named that (by default it is init() ).

Users can specify an exported name which needs to be explicitly called. This allows initialization to be explicit to avoid doing it in cases where it is not needed.

scudette commented 5 years ago

Ref: #45

UnnoTed commented 5 years ago

This solution raises a problem in spread mode because theres a init function in each file, renaming it will cause a name collision.

scudette commented 5 years ago

Does it make sense to put all the init functions in the same file - even in spread mode? Maybe an init.go which takes care of all initialization - the actual string definitions can be kept in spread files.

UnnoTed commented 5 years ago

Yes, that'll work, just remove the spread condition from: https://github.com/UnnoTed/fileb0x/blob/master/template/files.go#L11 https://github.com/UnnoTed/fileb0x/blob/master/template/files.go#L85

then remove init() and imports from: https://github.com/UnnoTed/fileb0x/blob/master/template/file.go