Enable more linters, address the issues and do a major naming refactor
to use golang lower camelCase identifiers for types, functions, methods
and variable names.
Also:
* Clean up inline generation so it doesn't rely on temporary variables.
* Remove unused functions generated by inline.pl.
When putting JavaScript objects into _go*object use exported values.
This reverts PR #467 in favour of this more complete work.
Fixes#118#252
Co-authored-by: Dmitry Panov <dop@itoolabs.com>
Enable the whitespace linter and fix the errors resulting from it.
Also:
* Remove unneeded golangci-lint config for disabled linters.
* Correct test number for panic in previous commit.
Value and Object now conform to the json.Marshaler interface and produce the
correct JSON when passed (directly or indirectly) to json.Marshal().
Before, both types would marshal as "{}" because they're structs with no public
fields.
This fixes some nasty problems marshaling object trees that mix Go and JS
collections. This can happen when you pass a Go collection into a JS function,
which modifies it adding JS values; and then back in Go you marshal the
collection to JSON. Before this commit the JS values would marshal to "{}".
(The new unit test TestNestedJSONMarshaling demonstrates this.)
Fixes#262
Disable new linters which aren't compatible with this code module.
Upgrade github actions to fix caching issues.
Run go mod to bring in new styling.
Remove space on nolint declarations.
Apply all changes to whitespace as required to pass goimports linter.
Only trigger checks on pull_request which works for pulls from other
forks, where as push only works from the same repo.
Fix a panic in value export when an array has multiple types of arrays.
This takes into account the types of elements in sub arrays, slices, etc.
Fixes#279Fixes#377
Leverage github actions for tests and linting.
This includes fixing a bunch of issues highlighted by golangci
including:
* Dead code.
* Ineffectual assigns.
* Goto warnings.
* Nil return err.
* Reused literal strings.
* Test parameter order.
Also:
* Setup clog.
* add stackFramesToPop argument to error factories
* put native functions in their own stack frames
* add tests for native stack frames
* amend Context functionality to account for native frames
Previously, it was a publically accessible but invalid value (valueEmpty).
* Deprecate internal use of UndefinedValue(), NullValue(), FalseValue(), TrueValue()
* Guard against Empty, Result, Reference values from escaping the package
* Faster, more straightforward, etc.
* More advanced object literals (get ..., set ...)
* More tests using JavaScript from the wild (http://cdnjs.com/)
This fixes#45
The errors are manifest in the README, but this is automatically generated from the go documentation, so we have to fix them at the source
* Context setup is now done via _newContext.
* _newContext is a function that resides in inline.go. _newContext is very flat,
resulting in almost no function calls (a 180 from the earlier status quo).
* inline.go is a Go source file that is built by Perl (via inline).
* Lots of crufty functions removed (along with all of their TODO & FIXME).
* In addition, before, the underlying value of _object.value was a pointer to
something. This made for extra work, since the type of _object.value is interface{},
which is already something of a pointer. Now, the underlying value of _object.value
in Function, Date, RegExp, ..., is a struct value.
* type_function.go was streamlined, removing superfluous struct fields and methods.
* There is now less "digging" to get to the actual value of a function, which is important
when makings lots of calls.
Before (without inline):
PASS
BenchmarkNew 2000 1067871 ns/op
ok github.com/robertkrimen/otto 3.336s
PASS
BenchmarkNew 2000 1077644 ns/op
ok github.com/robertkrimen/otto 3.367s
After (with inline):
PASS
BenchmarkNew 10000 364418 ns/op
ok github.com/robertkrimen/otto 4.616s
PASS
BenchmarkNew 10000 307241 ns/op
ok github.com/robertkrimen/otto 4.051s
This (partially) fixes#22