-
Notifications
You must be signed in to change notification settings - Fork 16
Description
This is a blanket ticket for going through the codebase and doing general cleanup and API fixes to make the code more idiomatic from a Go point of view.
Examples:
-
More functions should return
errorobjects to communicate failure conditions rather than relying on "magic" return values like empty strings.- e.g.
func ClearUservars(username string) errorcould return an error when the user had no vars to clear. - e.g.
func CurrentUser() (string, error)where it gives an error when called outside of an object macro context, rather than what it currently does by returning an empty string -- this isn't idiomatic Go.
- e.g.
-
User variable getter functions should be refactored to make more sense for "API context" vs. "internal use w/
<get>"- The public API functions like
GetUservar()should follow Go idioms and return"", errorin case of errors rather than"undefined", error - The internal use of the functions for the
<get>types of tags would handle the mapping of""to"undefined"for their own use.
- The public API functions like
-
Find a way to make the constructor config object easier to get and use. It's stupid to need to import
aichaos/rivescript-go/configto get theconfig.Config{}type for initializing RiveScript. The config type should be available directly from the parent package.This might require refactoring to make the parent package include more logic for config handling rather than just proxying all methods through to the
/srcversions, but that's probably a good thing anyway. The/srcpackage is private use only and I already spelled out in its docs that its API can be changed at any time without notice.bot := rivescript.New(rivescript.BasicConfig())