| Age | Commit message (Collapse) | Author |
|
With help of spdxconv tool [1], we able to bulk update all files license
and copyright format to comply with SPDX formats.
[1] https://kilabit.info/project/spdxconv/
|
|
The "nolint" tag is used to ignore lines from being processed by
golangci-lint.
Since we are not using golangci-lint anymore, now and in the
future, those lines can be removed.
|
|
|
|
Some of warnings from those linter are false positives, so we just
annotated them.
|
|
For HTTP server that use TLS, set the minimum TLS version and
ReadHeaderTimeout to mitigate slowloris attack.
For HTTP client or server that parameterize the use of InsecureSkipVerify,
annotate the line with "nolint:gosec" to allow the code pass the check.
Library that still use sha1, in example in DKIM and TOTP, skip the
warnings by annotating the line with "nolint:gosec".
A pointer variable now allocated their address before assigning its
value.
Any error that returned now wrapped using "%w".
Also, replace error checking using [errors.Is] or [errors.As] instead of
using equal or not-equal operators.
In "lib/http", replace any usage of "math/rand" with "crypto/rand".
Any call of [math/big.Rat.SetString] now annotated with "nolint:gosec"
since its false positive, the issue has been fixed in Go >= 1.17.7.
Any switch case that does not cover the rest of the possible values now
handled by adding the cases or by replacing the "default" case with
the rest of values.
|
|
HTTP request now implicitly create request with context.
Any false positive related to not closing HTTP response body has been
annotated with "nolint:bodyclose".
In the example code, use consistent "// Output:" comment format, by
prefixing with single space.
Any comment on code now also prefixing with single space.
An error returned without variables now use [errors.New] instead of
[fmt.Errorf].
Any error returned using [fmt.Errorf] now wrapped using "%w" instead of
"%s".
Also, replace error checking using [errors.Is] or [errors.As], instead
of using equal/not-equal operator.
Any statement like "x = x OP y" now replaced with "x OP= y".
Also, swap statement is simplified using "x, y = y, x".
Any switch statement with single case now replaced with if-condition.
Any call to defer on function or program that call [os.Exit], now
replaced by calling the deferred function directly.
Any if-else condition now replaced with switch statement, if possible.
|
|
There are several reasons that why we move from github.com.
First, related to the name of package.
We accidentally name the package with "share" a common word in English
that does not reflect the content of repository.
By moving to other repository, we can rename it to better and unique
name, in this "pakakeh.go".
Pakakeh is Minang word for tools, and ".go" suffix indicate that the
repository related to Go programming language.
Second, supporting open source.
The new repository is hosted under sourcehut.org, the founder is known
to support open source, and all their services are licensed under AGPL,
unlike GitHub that are closed sources.
Third, regarding GitHub CoPilot.
The GitHub Terms of Service [1], allow any public content that are hosted
there granted them to parse the content.
On one side, GitHub helps and flourish the open source, but on another
side have an issues regarding scraping the copyleft license [2].
[1]: https://docs.github.com/en/site-policy/github-terms/github-terms-of-service#4-license-grant-to-us
[2]: https://githubcopilotinvestigation.com
|
|
There are some reports that I disagree with revive, in example, code
should not declare the type after variables.
In my opinion, on some cases, declaring the type make the code more
readable and explicit.
Since I did not want to add new configuration file, we changes it and
follow revive for now.
|
|
|
|
|
|
In latest Go release, calling Rat.SetString("-0") result in 0 instead
of -0.
|
|
Previously, the AddFloat function only accept two interface parameters.
This changes make the AddFloat to accept many interface parameters.
|
|
The following types is added and can be initialized to Float: []byte,
uint, uint16, uint32, uint64, big.Int, *big.Int, big.Rat, and *big.Rat.
|
|
The following alignment reported and fixed by fieldaligment tool,
float_test.go:103:13: struct with 16 pointer bytes could be 8
float_test.go:254:13: struct with 16 pointer bytes could be 8
big/float_test.go:302:13: struct with 32 pointer bytes could be 16
|
|
The promise of this package is to provide the Rat type with RoundToZero
and without panic.
In order to do that we remove the MustRat() function and check for nil
on pointer receiver before doing operation, and check for zero value
when doing quotation.
Another breaking changes are,
* Humanize() with nil pointer receiver will return string "0"
* Any IsXxx() methods with nil pointer receiver will return false
* MarshalJSON() will nil pointer receiver will return "null" instead of
"0" now
|
|
Previously, if the first parameter of Quo or the second/next parameters
of QuoRat is not convertable to Rat or zero, the method/function will
panic.
This changes make it less intrunsive, instead of panic we check for
zero value and return nil immediately.
|
|
|
|
The Add method simplify addition of one value to current Int.
The IsLess and IsGreater method simplify comparing Int with any value.
The Scan method allow the Int to be used on sql Scan().
|
|
The IsZero method will return true if the current i value is zero.
|
|
|
|
|
|
The standard big.Int does not implement sql/driver.Valuer interface,
which make it not usable when querying or doing update/insert with
database.
This commit extend the big.Int and simplify creating new Int from any
values using NewInt().
|
|
|
|
Previously, the test.Assert and test.AssertBench functions has the
boolean parameter to print the stack trace of test in case its not equal.
Since this parameter is not mandatory and its usually always set to
"true", we remove them from function signature to simplify the call
to Assert and AssertBench.
|
|
The Rat.Value() return the value as []byte.
|
|
The RoundNearestFraction does not require precision parameter, like in
other rounds function, but it figure it out based on the last non-zero
value from fraction.
|
|
By doing this we got unit test and example in documentation.
|
|
The Humanize method return the r as string with custom thousand and
decimal separator.
|
|
To prevent the test error when running with different Go version, we
use the strings.Contains to compare the error instead of using
test.Assert directly.
|
|
The new Assert function use the reflect.DoEqual that return an error
which describe which field have unmatched value.
This changes affect other test that use "false" as the last parameter.
|
|
The Go tip add prefix "json:" when there is an error on UnmarshalJSON.
|
|
RoundToNearestAway round r to n digit precision using nearest away mode,
where mantissa is accumulated by the last digit after precision.
For example, using 2 digit precision, 0.555 would become 0.56.
RoundToZero round r to n digit precision using to zero mode.
For example, using 2 digit precision, 0.555 would become 0.55.
|
|
MarshalJSONAsString define the default return behaviour of MarshalJSON().
If its true (the default) the returned JSON format will encapsulated in
double quote, as string instead of as numeric.
|
|
|
|
|
|
|
|
If the slice of byte or string is zero the returned Rat value will be 0.
|
|
|
|
The check for method IsEqual only happened if type is struct.
This changes affect the test on package math/big.
|
|
|
|
|
|
|
|
|
|
|
|
Turn out strconv.ParseInt will return an error when passing string with
decimal separator, for example "1.1".
|
|
|
|
Using Rat.Float64() and converting it to int64 cause some rounding issue
on some number, for example result of multiply "4011144900.02438879"
with 100000000.
|
|
The "big" package add custom global precision, rounding mode, and number
of digit precision after decimal point for all instance of Float that
use the package.
|