olivia icon indicating copy to clipboard operation
olivia copied to clipboard

Olivia Server Relies On Unexported Global Variable Yet Exposes Public Functions

Open bonedaddy opened this issue 5 years ago • 4 comments

server/serve.go relies on an unexported global variable called neuralNetworks which is set when running server.Serve however it exposes public functions like Reply and Train.

The inability to set neuralNetworks unless calling server.Serve negates the purpose of having public accessible functions like Reply and Train as these can't be used, unless you call server.Serve.

neuralNetworks should either be a publicly settable and gettable variable, or all public functions like Reply and Train should not be public, as they wont work unless you call server.Serve.

This means that its not possible to use the olivia server in third-party packages or repositories, even though it is written in such a way that it can be used by third party packages or repositories.

bonedaddy avatar Jun 19 '20 05:06 bonedaddy

The suggestion is accurate and I will change that. However, Olivia isn’t a library and it isn’t built to be a package used externally.

hugolgst avatar Jun 19 '20 06:06 hugolgst

Ah okay understandable. Is there any kind of limitation that would prevent it from being used as a library? It definitely is a one of a kind golang project, and in theory would allow people to build some cool stuff being used as a library.

bonedaddy avatar Jun 19 '20 06:06 bonedaddy

It is a great idea, however every part of the project relies on another one and it is a big puzzle. If you have any suggestions that would be great!

hugolgst avatar Jun 19 '20 06:06 hugolgst

Ah okay that makes sense, I will think and let you know if I can think of anything else :D

bonedaddy avatar Jun 19 '20 18:06 bonedaddy