| Age | Commit message (Collapse) | Author |
|
|
|
|
|
The call to get "GET <Webhook.URL.Path>/<Token>" will return HTTP status
200 with JSON body '{"code":200,"message":"OK"}'.
This endpoint is to check if the bot server is really running.
|
|
|
|
Using [path.Join] cause "https://domain" become "https:/domain" which
is not a valid URL.
|
|
Instead of returning three variables, [http.Response], []byte, and error,
we combine the [http.Response] and []byte into single struct:
ClientResponse.
|
|
|
|
The NewServer and NewClient now accept non-pointer options, so the
caller unable to modify the options once the server or client has
been created.
|
|
Once the endpoint registered, the caller should not able to changes
any values on endpoint again.
|
|
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.
|
|
Instead of annotating the lines that caught by linters, fix it to comply
with the recommendations.
This causes several breaking changes, especially related to naming,
* api/slack: [Message.IconUrl] become [Message.IconURL]
* lib/dns: DefaultSoaMinumumTtl become DefaultSoaMinimumTTL
* lib/email: [Message.SetBodyHtml] become [Message.SetBodyHTML]
* lib/http: [Client.GenerateHttpRequest] become
[Client.GenerateHTTPRequest]
* lib/http: [ClientOptions.ServerUrl] become [ClientOptions.ServerURL]
* lib/http: [EndpointRequest.HttpWriter] become
[EndpointRequest.HTTPWriter]
* lib/http: [EndpointRequest.HttpRequest] become
[EndpointRequest.HTTPRequest]
* lib/http: [ServerOptions.EnableIndexHtml] become
[ServerOptions.EnableIndexHTML]
* lib/http: [SSEConn.HttpRequest] become [SSEConn.HTTPRequest]
* lib/smtp: [ClientOptions.ServerUrl] become [ClientOptions.ServerURL]
* lib/ssh/sftp: [FileAttrs.SetUid] become [FileAttrs.SetUID]
* lib/ssh/sftp: [FileAttrs.Uid] become [FileAttrs.UID]
|
|
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.
|
|
The shadow tool [1] report a variable where its name is declared twice
or more, in different scope.
[1] https://pkg.go.dev/golang.org/x/tools@v0.13.0/go/analysis/passes/shadow
|
|
The realignment reduce the size of the following struct (in bytes),
* Audio: from 112 to 104 (-8)
* Bot: from 88 to 72 (-16)
* Chat: from 160 to 144 (-16)
* Command: from 40 to 32 (-8)
* struct in TestCommand_validate: from 72 to 64 (-8)
* Contact: from 64 to 56 (-8)
* Document: from 80 to 64 (-16)
* EncryptedPassportElement: from 144 to 136 (-8)
* Game: from 104 to 88 (-16)
* InlineKeyboardButton: from 96 to 88 (-8)
* InlineQuery: from 64 to 56 (-8)
* Message: from 544 to 488 (-56)
* MessageEntity: from 64 to 48 (-16)
* MessageForward: from 56 to 40 (-16)
* messageRequest: from 80 to 56 (-24)
* struct in TestMessage_parseCommandArgs: from 576 to 520 (-36)
* Options: from 32 to 24 (-8)
* OrderInfo: from 56 to 48 (-8)
* PassportData: from 64 to 56 (-8)
* PreCheckoutQuery: from 88 to 72 (-16)
* response: from 56 to 32 (-24)
* ShippingQuery: from 48 to 40 (-8)
* Sticker: from 136 to 112 (-24)
* SuccessfulPayment: from 88 to 80 (-8)
* Update: from 96 to 88 (-8)
* User: from 64 to 56 (-8)
* Venue: from 72 to 56 (-16)
* Webhook: from 96 to 72 (-16)
* WebhookInfo: from 64 to 40 (-24)
|
|
|
|
|
|
This is for clarity in the code, better to be explicit by typing where
the field or methods come from.
|
|
|
|
Since Go 1.16, the ioutil package has been deprecated.
This changes replace any usage that use functions from ioutil package
with their replacement from package os or package io.
|
|
Previously, the NewClient function accept three parameters: serverURL,
http.Header, and insecure. If we want to add another parameter,
for example timeout it will cause changes on the function signature.
To prevent this changes in the future, we change it now. The NewClient
now accept single struct.
While at it, we add option to set Timeout.
The Timeout affect the http Transport Timeout and TLSHandshakeTimeout.
The field is optional, if not set it will set to 10 seconds.
|
|
Previously, parameters to method Delete, Get, Post, PostForm, PostFormData,
PostJSON, Put, and PutJSON are in the following order:
(headers, path, params)
This is sometimes confusing. To make it better and works with format
of HTTP request header,
METHOD PATH
HEADERS
PARAMS
we move the path to the first parameter and headers as the second
parameter, so the call to client methods would be
(path, headers, params)
|
|
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.
|
|
Previously, the parameters to Callback has three types:
the http.ResponseWriter, *http.Request, and []byte for response body.
Not only the type names are long, there is no information on the
registered Endpoint on the receiver of Callback.
This changes wrap the three parameters into single type EndpointRequest
with addition field Endpoint, which contains the registered Endpoint.
On the CallbackErrorHandler we also have three parameters, but instead
of request body we have an error.
This changes store the error for CallbackErrorHandler inside
EndpointRequest.Error field.
|
|
Unlike PostWebhook API which is close and open one connection at the
time, the WebhookClient is keep open.
Use the WebhookClient for long running program that post message every
minutes or seconds.
|
|
This package only depends on standard packages.
Currently, it provide function to send message using incoming webhook
URL.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
This changes update the http.Client in api/telegram/bot.
|
|
|
|
|
|
|