| 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/
|
|
|
|
Now that Go has type parameter, we can use it to use the same function
that accept different types for working with slice of int, int64.
|
|
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
|
|
The original idea of providing Now is to mock the current time in
testing Scheduler.
Since this variable can be overridden by other packages, it is not safe
to export it, hence we un-export it here so it can be used internal only.
|
|
Both of those methods has been added into standard library as
[Time.UnixMicro] and [Time.UnixMilli] since Go 1.17.
|
|
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.
|
|
While at it, realign struct in TestScheduler_minutely from 48 to 40 bytes.
|
|
This allow user to call the Next method, to know the next time the
scheduler will be triggered, after receiving the event.
|
|
The lib/io#Reader will be deprecated and replaced with lib/bytes#Parser
in the future.
|
|
Using time.Duration give better ticker precision, minimize panic due to
checking for <= 0 value for Reset.
|
|
We found dead code in parseListTimeOfDay and way to simplify getting
default minute in nextHourly.
|
|
This is for better readibility on the comment section.
|
|
Due to copy, paste and lack of testing, some condition should be
check using < instead of >.
While at it, add other examples for full test coverage.
|
|
Previously, testing NewScheduler cause a new goroutine run for each
call and this is slow.
To simplify it, we split the parser and create internal newScheduler
that accept the schedule and current time.
|
|
Previously, we calculate the ticker to every 60 seconds or less.
This require additional computation on how many seconds left after the
previous tick and sometimes cause panic if the nextSeconds is zero.
In this changes, we use the nextSeconds directly as duration of ticker.
|
|
The Next method return the next schedule.
This changes require refactoring on each calculation on schedule by
returning the next time.Time instead of setting it inside directly, which
affect on simplification of nextMinutely and nextHourly.
|
|
Scheduler is a timer that run periodically based on calendar or day time.
A schedule is divided into monthly, weekly, daily, hourly, and minutely.
An empty schedule is equal to minutely, a schedule that run every minute.
|
|
Clock represent 24 hours time with hour, minute, and second.
An hour value is from 0 to 23, a minute value is from 0 to 59, and
a second value is from 0 to 59.
|
|
The Now variable return the current local time.
Unlike standard library, this is a variable that can be override to mock
the current time during testing.
|
|
Since we only need to call Log and Fatalf during Assert, no need to pass
the whole instance of testing.T to Assert.
By changing it to Writer, we also can test the Assert.
This remove the AssertBench, because it have the same function
parameters and body as Assert.
|
|
|
|
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.
|
|
While at it, replace the unit tests with an example so we can both do
unit testing and provide an examples in documentation.
|
|
|
|
|
|
|
|
|
|
This library previously part of bytes package. To make it bytes package
consistent (only working with slice of byte), we move all ASCII related
constants, variables, and functions into new package.
|
|
The valid syntax to suppress linter warnings is "//nolint:<name>" with
no space between comment and "nolint" and between ":". Also, we move the
placement of nolint directive to the top of statements for multiple
nolint in the same scope.
While at it, fix and supress some linter warnings.
|
|
Most of the warnings caused by update to linter which cause global
variables declared with grouping "( ... )" and that has been suppressed,
are become false-positive again.
|
|
Micro seconds is the first six digits after seconds in output of
UnixNano().
|
|
|
|
|
|
Also, add more unit tests for false positive and simplify code.
|
|
This package provide library for parsing email message format as
specified in RFC 5322.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|