summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2022-08-05Release share v0.40.0 (2022-08-05)v0.40.0Shulhan
=== Breaking changes * lib/memfs: set the Root SysPath to the first MemFS instance on Merge * lib/memfs: rename Option field Development to TryDirect === New features * _bin: add script to run Go benchmark * _bin: add script to run Go test and generate HTML coverage * _bin: add script go-mod-tip.sh * cmd/epoch: print the weekday in local and UTC time * cmd/epoch: add flag to parse time from RFC3339 and RFC1123 format * cmd/ini: a CLI to get and set values in the INI file format * lib/test: implement Data, a type to load formatted file for helping test === Bug fixes * lib/ini: fix parsing and saving multi line variables * lib/ini: fix marshaling pointer to nil field * lib/memfs: ignore error on Get when calling node Update === Enhancements * lib/dns: add field SOA to the ServerOptions * lib/http: add server options to generate index.html automatically * lib/ini: support escaped double-quote and colon in tag subsection * lib/ini: handle marshaling slice of time.Time
2022-08-05all: simplify and remove unused tasks in MakefileShulhan
2022-08-05_bin: add script to run Go benchmarkShulhan
The go-bench.sh accept two arguments: the method or function to benchmark, default to "."; and benchmark number, default to current timestamp YYYYmmDD-HHMM.
2022-08-03lib/memfs: suppress linter warnings for sending to channel using selectShulhan
The idea on using select is to prevent the process being blocked when sending to channel that is already full.
2022-08-03lib/dns: add field SOA to the ServerOptionsShulhan
The SOA field defined the root authority for all zones and records served under the Server.
2022-08-03lib/strings: update comment format on CleanWikiMarkupShulhan
2022-08-03lib/strings: clean up test codesShulhan
Changes, * Use test.Data for test that require longer text input and output * Replace variable declaration ":=" with explicit one. * Use literal string
2022-08-03lib/http: add server options to generate index.html automaticallyShulhan
If the EnableIndexHtml in the ServeOptions enabled, server generate list of files inside the requested path as HTML.
2022-08-03lib/memfs: add method to generate index.html in Node's ContentShulhan
The GenerateIndexHtml generate simple directory listing as HTML for all child in the node. This method is only applicable if node is a directory.
2022-08-03lib/memfs: simplify code by using return-first and else conditionShulhan
2022-08-03lib/mlog: simplify for-select channel consumers with for-rangeShulhan
2022-07-29lib/websocket: reformat and paraphrase some commentsShulhan
2022-07-29lib/websocket: fix possible data race on client testShulhan
We only do lock on exported methods, but when doing testing we call the send method without lock which cause read and write on Client.conn at the same time.
2022-07-27lib/dns: change the TLS listen port when testingShulhan
This is to prevent the test failed due to the same port number (8053) has already been used (another DNS server already running).
2022-07-27all: add PKGBUILD for shared tools in cmdShulhan
The PKGBUILD create Arch package named share-tools. Its include command epoch, ini, and xtrk.
2022-07-27_bin: add script to run Go test and generate HTML coverageShulhan
The script accept one single argument: the path to package to be tested. If its empty default to current directory and sub-directories.
2022-07-27_bin: add script go-mod-tip.shShulhan
The go-mod-tip shell script get and print the latest Go module version based on the last tag and the latest commit hash from the current working directory. This command usually used to fix go.mod due to force commit.
2022-07-27all: make the share.Version in the command to be dynamicShulhan
Instead of using only the last tagged version use the last tag plus latest commit hash. This changes require the Version and other constants that use it to be declared as variable.
2022-07-27make: cleaning up and simplify MakefileShulhan
Add new task: "build" to build all cmd into _bin/linux-amd64 directory. Set the default "all" task to test, lint, and then build. Remove the $SRC and $SRC_TEST to minimize disk read, let the Go figure it out if the package need to be build and/or test.
2022-07-27cmd/gofmtcomment: add command "help" and "version"Shulhan
While at it, expand the usage to describe the synopsis, arguments, and example of command. Also, replace any variable assignment from ":=" to explicit variable with type.
2022-07-27cmd/xtrk: add command "help" and "version"Shulhan
2022-07-27cmd/epoch: print the weekday in local and UTC timeShulhan
2022-07-27cmd/epoch: add flag to parse time from RFC3339 and RFC1123 formatShulhan
The flag for RFC1123 comes with two options one with string timezone (-rfc1123) and one with numeric time zone (-rfc1123z).
2022-07-27cmd/epoch: add command "help" and "version"Shulhan
2022-07-27cmd/ini: a CLI to get and set values in the INI file formatShulhan
This is the CLI that implements the lib/ini for getting and setting the key's value from INI file.
2022-07-27lib/ini: fix parsing and saving multi line variablesShulhan
Previously, if INI file contains multi line variables, for example key = a \ b The Get and saved value is "a \tb", where it should be "a b" for Get and "a \\\n\t\b" again when saved. This changes require refactoring how the variable's value is parsed and stored. A variable value is parsed and stored from character after "=" until new line or comment as raw value, and the real value is derived by trimming white spaces, handle escaped character and double quotes.
2022-07-26lib/ini: parse comment as part of formatShulhan
Previously, the comment is parsed and stored separately. This changes make the comment as part of format.
2022-07-26lib/ini: record benchmark result for Parse in separate fileShulhan
While at it, rewrite the benchmark code to call Parse instead of reader.Parse and reset the timer after loading the file.
2022-07-25lib/ini: export the function to parse tagShulhan
2022-07-25lib/xmlrpc: rewrite the test using test.DataShulhan
2022-07-25lib/test: truncate the last new line at the end of input and outputShulhan
Given the following input and output, >>> input <<< output EOF The input and output content always have new line at the end. This may cause unexpected input or output. If input or output content expecting new line at the end, add two empty lines at the end of it.
2022-07-23lib/test: sort the loaded test Data filesShulhan
This is to make the list of files being tested is consistent.
2022-07-23lib/test: load test data files with suffix "_test.txt"Shulhan
Previously, the LoadDataDir load all files from directory that have ".txt" extension. This may cause unknown non-test data files loaded and may cause an error. To distinguish it with other text files, inside the directory to be loaded load only the file that has suffix "_test.txt".
2022-07-23lib/ini: convert the Get test using test.DataShulhan
2022-07-23lib/ini: support escaped double-quote and colon in tag subsectionShulhan
A colon `:` is escaped using double backslash `\\`, for example `a:b\\:c:d` contains section `a`, subsection `b:c`, and variable `d`. A double quote `"` is escaped using triple backslash, for example `\\\"`.
2022-07-22lib/ini: refactoring test to use test.DataShulhan
2022-07-22lib/ini: handle marshaling slice of time.TimeShulhan
2022-07-22lib/ini: fix marshaling pointer to nil fieldShulhan
If the field is pointer, the code will thrown panic if its point to nil struct or print "<invalid reflct.Value>" for String.
2022-07-22lib/test: implement Data, a type to load formatted file for helping testShulhan
Data contains predefined input and output values that is loaded from file to be used during test. The data provides zero or more flags, an optional description, zero or more input, and zero or more output. The data file name must end with ".txt". The data content use the following format, [FLAG_KEY ":" FLAG_VALUE LF] [LF DESCRIPTION] ">>>" [INPUT_NAME] LF INPUT_CONTENT LF "<<<" [OUTPUT_NAME] LF OUTPUT_CONTENT The data can contains zero or more flag. A flag is key and value separated by ":". The flag key must not contain spaces. The data may contain description. The line that start with "\n>>>" defined the beginning of input. An input can have a name, if its empty it will be set to "default". An input can be defined multiple times, with different names. The line that start with "\n<<<" defined the beginning of output. An output can have a name, if its empty it will be set to "default". An output also can be defined multiple times, with different names.
2022-07-19lib/test: realign struct in the testShulhan
2022-07-16go.mod: update all dependenciesShulhan
2022-07-16lib/memfs: set the Root SysPath to the first MemFS instance on MergeShulhan
Previously, calling Merge(...), set the merged MemFS Root.SysPath to "..". Since we allow the TryDirect to access the file directly (if its set to true), this may cause the file system leaks if returned MemFS set this flag to true. To prevent that, we set the SysPath to the first MemFS SysPath.
2022-07-16email/dkim: skip test that require external DNS recordsShulhan
Due to external DNS records are unpredictable, some test may failed in the future.
2022-07-09lib/memfs: rename Option field Development to TryDirectShulhan
This changes the usage of Development flag. TryDirect define a flag to bypass file in memory. If its true, any call to Get will try direct read to file system. This flag has several use cases. First, to test serving file system directly from disk during development. Second, to combine embedded MemFS instance with non-embedded instance. One is reading content from memory, one is reading content from disk directly.
2022-07-07lib/memfs: ignore error on Get when calling node UpdateShulhan
If node exist in memory, error on Update does not means the file is not exist. The node may have been embedded and then merged with other MemFS instance with Development flag set to true.
2022-07-03Release share v0.39.0 (2022-07-03)v0.39.0Shulhan
Breaking changes * all: move lib/sanitize.HTML to net/html.Sanitize New features, * lib/mlog: add method Close to MultiLogger * lib/clise: implement json.Marshaler on Clise * net/html: add function NormalizeForID * lib/http: add function to unmarshal url.Values using tag `form:` * lib/reflect: implement Set function to set reflect.Value by string * lib/reflect: add function Unmarshal * lib/reflect: add function Tag to simplify lookup on struct's field tag Enhancements, * lib/memfs: update the template format * net/html: use inline replacement to clean up white spaces * lib/mlog: minimize allocation when generating log * lib/dns: use Shutdown to stop DoH server * lib/websocket: realign all struct to minimize allocations
2022-07-03doc: split changelog files by yearShulhan
Since we release each month, the changelog growth bigger every times. In order to focus reader to latest changes, we move old changelogs to another files grouped by year.
2022-07-02lib/memfs: update the template formatShulhan
Replace ":=" with "var" and realign the field assignments.
2022-07-02net/html: use inline replacement to clean up white spacesShulhan
Instead of using bytes.Replace, three times, iterate the plain text manually to clean up the white and multiple spaces. Benchmark result, name old time/op new time/op delta Sanitize-8 4.27µs ±10% 2.64µs ±13% -38.21% (p=0.000 n=10+10) name old alloc/op new alloc/op delta Sanitize-8 4.84kB ± 0% 4.45kB ± 0% -7.94% (p=0.000 n=10+10) name old allocs/op new allocs/op delta Sanitize-8 13.0 ± 0% 6.0 ± 0% -53.85% (p=0.000 n=10+10)
2022-06-27all: move lib/sanitize.HTML to net/html.SanitizeShulhan
Since the sanitize package only contains HTML function, and the html package already exist, we move the function into html package.