| 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/
|
|
Checking if child is nil is impossible here, because the AddChild create
and return new child.
|
|
Go 1.22 now support for-range on numeric value.
|
|
|
|
On server with TryDirect is true, any GET request to a directory should
always rescan the content and the generate the new index.html.
While at it, return the generated time in UTC instead of local time.
|
|
The GoEmbed test that write Go embedded code into "internal/test/embed/"
may create unnecessary changes when the test run on new clone of this
repository, or when we run "go test" again on that package after rebasing.
|
|
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.
|
|
Package hexdump implements reading and writing bytes from and into
hexadecimal number.
It support parsing output from hexdump(1) tool.
|
|
The watchfs package now contains the original, v1, of the
Watcher and DirWatcher types.
This changes require exporting method
[memfs.MemFS.UpdateContent].
|
|
|
|
This changes move the following fields and methods from MemFS,
* incRE and excRE fields to Options,
* isIncluded and isExclude methods to Options,
* watchRE field to WatchOptions,
* isWatched method to WatchOptions.
The reason is to allow other type that use Options or WatchOptions to use
isIncluded, isExclude, or isWatched methods.
|
|
While at it, temporary disable gosec due to excessive report for G115,
which may be true, but may also break the current working program.
We should alter and fix once we can test and make sure that it does not
breaks.
|
|
Compared it with "go:embed", the memfs package is more flexible and
portable.
Currently, we found three disadvantages of using "go:embed",
#1 - The "go:embed" only works if files or directory to be
embedded is in the same parent directory.
#2 - Accessing the embedded file require the original path.
#3 - No development mode.
|
|
In previous commit we use wrong condition when handling directory "." as
Root.
|
|
In [MemFS.refresh], if the requested url is "/file1" and [Options.Root]
is ".", the path during refresh become "file1" and if passed to
[filepath.Dir] it will return ".".
This cause the loop on refresh never end because there is no PathNodes
equal with ".".
|
|
Using octal in mode make the code more readable, for example mode with
permission "0o644" much more readable than 420.
|
|
The MemFS always store directory without slash.
If caller request a directory node with slash, it will always return nil.
|
|
|
|
Putting "html" under "net" package make no sense.
Another reason is to make the package flat under "lib/" directory.
|
|
Some of warnings from those linter are false positives, so we just
annotated them.
|
|
The Merge function has been replaced with [memfs.MemFS.Merge] for
better API.
|
|
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
|
|
This is to fix several flaky tests on ExampleDirWatcher [1].
[1] https://github.com/shuLhan/share/actions/runs/7765975142
[2] https://github.com/shuLhan/share/actions/runs/7672754239
|
|
The test is flaky because we use range over map of [tdata.Input].
Since range over map will return random key, there is possibility that
the first test is writing "/dir-a/dir-b/file2" not "/dir-a/dir-b/file".
|
|
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.
|
|
If the parameter withContent is true, which is default in MarshalJSON,
then all of the node content will be included in JSON output.
This also changes the parameter withoutModTime to withModTime because
working with negation make code not easy to read.
|
|
This implemented simplified version of merging multiple MemFS instances.
The sub file system (subfs) can be added to the parent MemFS instance
by calling new method "Merge".
parent.Merge(other *MemfS)
When Get method called, each subfs will be evaluated in order of Merge
called.
This deprecated the function Merge.
|
|
Another error for handling fs.ErrNotExist when scanning directory
which is may caused by broken symlink.
|
|
|
|
Instead of refreshing from the Root, find the directory that closes
to the requested path.
While at it, simplify the returned error.
|
|
The JSON method encode the Node into JSON.
This method provides an alternative to MarshalJSON with granular options,
depth and withoutModTime.
The depth set the level of childs to be encoded.
The depth=0 only encode the Root Node itself (with its childs), depth=1
encode the Root node and its subdirectories, and so on.
If withoutModTime is set to true, all of the node ModTime will not be
included in output.
|
|
If the path does not exist it will return long string,
Get: /path/relative/to/root: stat /ab/so/lu/te/path no such file or
directory
We simplify it to
Get "/path/relative/to/root": file does not exist
|
|
We try with 100ms but sometimes it stuck on the first <-dw.C.
|
|
|
|
When a directory being deleted we recursively unmap all its sub
directory.
When a file being deleted we stop its watcher.
|
|
Previously, the Watcher goroutine will stopped only if the file is
being deleted.
If the DirWatcher stopped manually, by calling Stop method, the
Watcher goroutine will still running in the background.
This changes record all spawned Watcher and stop it when files inside
a deleted directory or when Stop called.
|
|
Calling Ticker.Stop does not stop the "for-range", as shown in this
test:
var (
delay = 100 * time.Millisecond
tick = time.NewTicker(delay)
)
go func() {
time.Sleep(2 * delay)
tick.Stop()
}()
for range tick.C {
t.Logf(`ticking`)
}
t.Logf(`ticker stopped`)
the "ticker stopped" will never be printed.
This will cause the Watcher will leak goroutine.
|
|
If the FileInfo for Mode changes, update its value and keep going
to check for modification time or size.
While at it, update Readdir comment to reflect the actual FileInfo being
returned.
|
|
The original idea of embedding those interface is to guard the Node
implementation to always follow all methods in the os.FileInfo and
http.File, in case there is additional methods in the future.
But, embedding interfaces make the struct store it as field "FileInfo"
and File with "<nil>" values, which add storage cost to Node.
|
|
The original idea of mocking the os.Stat to allow running test without
adding Sleep, but this cause our tests a little bit flaky.
|
|
In this changes, we simplify re-scanning the directory content.
Instead of looping on node Childs to detect new or delete files, use map
to store previous Childs first.
If node path exist in map then add it again as child, otherwise delete it.
|
|
|
|
Previously, only node content get updated.
In case in the MemFS, user set "Options.TryDirect" to true, the directory
content should be updated too on "MemFS.Get".
|
|
Even thought empty directory does not contains file, from the parent
node _it is_ part of their content.
Also, there is a use case where memfs use as virtual file system (VFS),
as a layer with file system, where user can view list of directory,
create a directory or file on the fly.
If we skip scanning empty directory, that directory will not be visible.
|
|
By calling the Init method, the regular expression for include and
excludes is initialized, which allow using any method of MemFS instance
later, for example the Watch method.
While at it, fix the fields alignment in template code format.
|