| 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/
|
|
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.
|
|
|
|
|
|
|
|
The realign save storage spaces on struct,
* Node: from 240 to 224 bytes (-16 bytes)
* Options: from 112 to 104 bytes (-8 bytes)
* PathNode: from 16 to 8 bytes (-8 bytes)
|
|
Previously, the PathNode has two fields to store the node in memory,
one is "v" that store map of path to *Node and another is "f" that
store the map of path to function that return a *Node.
The "f" is used to handle embedding Go generated code, but since
the template now can handle generated dynamic path and Node this field
is not used anymore.
|
|
During Memfs Get(), if the node returned by PathNodes.Get() is null,
the memfs instance will try to refresh the directory tree. In case
the requested path exist, the memfs will write to PathNodes through
AddChild()
At the same time, there maybe a request to access another path, which
cause both read and write occured.
|
|
Previously, MarshalJSON on memfs will return an object of map
of all PathNodes and on Node it will return an object.
This changes make it the JSON response consistent. If its directory
it will return the node object with its childs, without "content".
If its file, it will return the node object with content.
While at it, use single "mod_time" with value is epoch and return
the node ContentType as "content_type".
|
|
Encoding the PathNode to JSON will include the content of each Node, but
encoding only single Node will include the content.
|
|
Previously, without MarshalJSON, encoding the MemFS or Node object will
result in incomplete information, for example, missing name, modification
time, and size.
This commit implement the json.Marshaler in MemFS which encode the
PathNode sorted by keys in ascending order.
|
|
|
|
Previous Go generated file use their own Node and provide single function
Get() to get the node based on path. This method does not work when
using it directly with memfs. For example, on server that contains
instance of memfs and want to use the output from GoGenerate, it would
need to add their own wrapper for Get() and memfs.Get().
It should be more simple than that.
This change add global variable GeneratedPathNode to memfs package, that
will be set by file from go generate. If the GeneratedPathNode is not
nil, memfs will use it as internal mapping of path and node.
|