fileb0x icon indicating copy to clipboard operation
fileb0x copied to clipboard

Added Init config variable.

Open scudette opened this issue 6 years ago • 4 comments

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 avatar Nov 22 '18 05:11 scudette

Ref: #45

scudette avatar Nov 22 '18 05:11 scudette

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

UnnoTed avatar Nov 26 '18 14:11 UnnoTed

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.

scudette avatar Nov 26 '18 14:11 scudette

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

UnnoTed avatar Nov 26 '18 16:11 UnnoTed