| Age | Commit message (Collapse) | Author |
|
This is the first release of pakakeh.go on the year 2025. There are many
new features and cleaning up, including packages that merged into single
package with help of type parameters.
The first major changes is indicated by using "go 1.23.4" as minimum Go
version in this module, to allow us using new packages like "slices" and
"maps".
In this release notes, we try new format. Instead of grouping each
changes by Breaking changes, New features, Bug fixes, Enhancements,
and/or Chores; we group them by package. Each paragraph in the package
sections will be prefixed with tag "[BREAKING CHANGE]", "[NEW FEATURE]",
"[BUG FIX]", "[ENHANCEMENT]", "[CHORE]" to indicates the type of
changes.
=== lib/binary
The "lib/binary] is new package that complement the standard binary
package.
[NEW FEATURE]
Implement append-only binary that encode the data using [binary.Writer].
We call them "Apo" for short.
[NEW FEATURE]
Implement buffer for reading/writing in BigEndian. The BigEndianBuffer
provides backing storage for writing (most of) Go native types into
binary in big-endian order. The zero value of BigEndianBuffer is an
empty buffer ready to use.
The following basic types are supported for Write and Read: bool, byte,
int, float, complex, and string. The slice and array are also supported
as long as the slice’s element type is one of basic types.
=== lib/bytes
[BREAKING CHANGE]
In the "lib/bytes" we split the hexdump related functions to separate
package, "lib/hexdump".
=== lib/floats64
[BREAKING CHANGE]
This package has been removed, merged into "slices" package.
=== lib/hexdump
[NEW FEATURE]
Package hexdump implements reading and writing bytes from and into
hexadecimal number. It support parsing output from hexdump(1) tool.
=== lib/http
[NEW FEATURE]
In the [lib/http.Client] we add new method Transport that return default
HTTP Transport. The returned [http.Transport] is created after the
Client instantiated. Their value can be customized by user when needed,
which should affect the Transport inside the Client.
=== lib/ints
[BREAKING CHANGE]
This package has been removed, merged into "slices" package.
=== lib/ints64
[BREAKING CHANGE]
This package has been removed, merged into "slices" package.
=== lib/memfs
[ENHANCEMENT]
In the "lib/memfs" we refactoring the Watch method to use the new
"watchfs/v2" package.
[BREAKING CHANGE]
The old Watcher and DirWatcher types now moved to watchfs package. This
changes require exporting method [memfs.MemFS.UpdateContent].
=== lib/numbers
[CHORE]
In the package level, we remove unused README and LICENSE files. This
package README has been merged into the package documentation and the
LICENSE is same with the module one.
We also remove some package documentation that should be in
"lib/slices".
=== lib/play
[NEW FEATURE]
The [lib/play] now has function and HTTP handler to run Go test code.
Since the test must run inside the directory that contains the Go file
to be tested, the [HTTPHandleTest] API accept the following request
format,
{
"goversion": <string>,
"file": <string>,
"body": <string>,
"without_race": <boolean>
}
The "file" field define the path to the "_test.go" file, default to
"test_test.go" if its empty. The "body" field contains the Go code that
will be saved to "file". The test will run, by default, with "go test
-count=1 -race $dirname" where "$dirname" is the path directory to the
"file" relative to where the program is running. If "without_race" is
true, the test command will not run with "-race" option.
[ENHANCEMENT]
On package level, the home and cache directory now initialized on
package init since there are never changes when program running. If Go
failed to get the home and cache it will be set to system temporary
directory.
[ENHANCEMENT]
We also simplify running Go code by removing the field pid in the struct
command that wait for process ID. Instead we execute cmd with Run
directly. In the Run function, we use the UnsafeRun to store temporary
directory and move the statements that writes go.mod and main.go into
the method writes of Request. This remove unnecessary unsafeRun
function.
=== lib/reflect
[BREAKING CHANGE]
This release changes the Equal signature from "Equal(v any) bool" to
"Equal(v any) error". The reason for this changes is to force the method
to return an error message that is understand-able by caller.
=== lib/slices
[NEW FEATURE]
Package "lib/ints", "lib/ints64", and "lib/floats64" are merged into
"slices". 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, and float64.
=== lib/ssh
[ENHANCEMENT]
In the lib/ssh, we implement Run with context internally. Instead of
depends on fork of crypto with CL that needs proposal, we implement them
in here so we can update crypto module to the latest release.
=== lib/watchfs
The watchfs package now contains the original, v1, of the Watcher and
DirWatcher types from "lib/memfs".
=== lib/watchfs/v2
[NEW FEATURE]
The "lib/watchfs/v2" is the new package that implement new file and
directory watcher, that replace the Watcher and DirWatcher in the
"lib/memfs".
The new implementation, FileWatcher, much more simple than what we have
in [memfs.Watcher].
The new directory watcher, DirWatcher, scan the content of directory in
[fs.DirWatcherOptions.Root] recursively for the files to be watched,
using the [fs.DirWatcherOptions.Includes] field. A single file,
[fs.DirWatcherOptions.FileWatcherOptions.FilePath], will be watched for
changes that trigger re-scanning the content of Root recursively.
The result of re-scanning is list of the Includes files (only files not
new directory) that are changes, which send to channel C. On each
[os.FileInfo] received from C, a deleted file have [os.FileInfo.Size]
equal to [NodeFlagDeleted]. The channel send an empty slice if no
changes.
The implementation of file changes in this code is naive, using loop and
comparison of mode, modification time, and size; at least it should
works on most operating system.
|
|
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.
|
|
BigEndianBuffer provides backing storage for writing (most of) Go native
types into binary in big-endian order.
The zero value of BigEndianBuffer is an empty buffer ready to use.
The following basic types are supported for Write and Read: bool, byte,
int, float, complex, and string.
The slice and array are also supported as long as the slice's element type
is one of basic types.
|
|
Add and remove missing packages under api/, program under cmd/, and
library under lib/ directory.
|
|
|
|
|
|
Now that Go has type parameter, we can use it to use the same function
that accept different types for working with slice of float64.
|
|
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.
|
|
This package README has been merged into the package and the LICENSE
is same with the module.
|
|
Package hexdump implements reading and writing bytes from and into
hexadecimal number.
It support parsing output from hexdump(1) tool.
|
|
The binary is new package that complement the standard binary package
Currently it implement append-only binary that encode the data using
[binary.Writer].
We call them "Apo" for short.
|
|
|
|
|
|
The watchfs package now contains the original, v1, of the
Watcher and DirWatcher types.
This changes require exporting method
[memfs.MemFS.UpdateContent].
|
|
|
|
DirWatcher scan the content of directory in [fs.DirWatcherOptions.Root]
recursively for the files to be watched, using the
[fs.DirWatcherOptions.Includes] field.
A single file, [fs.DirWatcherOptions.FileWatcherOptions.FilePath], will
be watched for changes that will trigger re-scanning the content of Root
recursively.
The result of re-scanning is list of the Includes files (only files not
new directory) that are changes, which will be send to channel C.
On each [os.FileInfo] received from C, a deleted file have
[os.FileInfo.Size] equal to [NodeFlagDeleted].
The channel will send an empty slice if no changes.
The implementation of file changes in this code is naive, using loop and
comparison of mode, modification time, and size; at least it should
works on most operating system.
|
|
The watchfs package contains new FileWatcher, more simple than what
we have in [memfs.Watcher].
|
|
We will needs slices and maps packages that are available since Go 1.23.
|
|
|
|
This changes the Equal signature from "Equal(v any) bool" to
"Equal(v any) error".
The reason for this changes is to force the method to return an error
message that is understand-able by caller.
While at it, simplify checking for Equaler interface in internal
doEqualStruct function.
|
|
While at it, set the ExpectContinueTimeout using the Timeout from
ClientOptions.
|
|
The returned [http.Transport] is created after the Client instantiated.
Their value can be customized by user when needed, which should affect
the Transport inside the Client.
|
|
Instead of depends on fork of crypto with CL that needs [proposal],
implement them in here so we can update crypto to the latest release.
[proposal]: https://go-review.googlesource.com/c/crypto/+/552435
|
|
This changes remove the field pid in the struct command that wait for
process ID, instead execute cmd with Run directly.
In the Run function, use the UnsafeRun to store temporary directory
and move the statements that writes go.mod and main.go into the method
writes of Request.
This remove unnecessary unsafeRun function.
|
|
|
|
The home and cache dir should never changes during a running program,
so we can set in once during package initialization.
If Go failed to get the home and cache it will be set to system temporary
directory.
|
|
The Test and HTTPHandleTest functions accept Request with File and Body
fields.
|
|
=== Enhancements
* lib/play: add custom request to run unsafe directory directly
As exceptional, the Run and HTTPHandleRun accept the following
request for running program inside custom "go.mod",
{
"unsafe_run": <path>
}
The "unsafe_run" define the path to directory relative to HTTP
server working directory. Once request accepted it will change the
directory into "unsafe_run" first and then run "go run ." directly.
Go code that executed inside "unsafe_run" should be not modifiable and
safe from mallicious execution.
* lib/play: add option to Run with specific Go version and without race
The idea is to allow testing Go code on specific Go version.
For example, before Go 1.22, the for loop with variable is shared
among block statements, which cause every use of that variable is run
with the last value.
* lib/play: expose the Timeout variable
By exposing the Timeout, user can set their maximum time the program
can run in their playground.
|
|
|
|
As exceptional, the Run and HTTPHandleRun accept the following
request for running program inside custom "go.mod",
{
"unsafe_run": <path>
}
The "unsafe_run" define the path to directory relative to HTTP
server working directory.
Once request accepted it will change the directory into
"unsafe_run" first and then run "go run ." directly.
Go code that executed inside "unsafe_run" should be not
modifiable and safe from mallicious execution.
|
|
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.
|
|
The idea is to allow testing Go code on specific Go version.
For example, before Go 1.22, the for loop with variable is shared
among block statements, which cause every use of that variable is run
with the last value.
|
|
By exposing the Timeout, user can set their maximum time the program
can run in their playground.
|
|
Eventhough the go.mod define go version 1.22.0, the [lib/play] use Go
version 1.23.2 for running testing.
|
|
This release update the minimum Go module to 1.22.0, the last version
supported by Go tools.
=== Breaking changes
* lib/http: remove writing StatusNoContent on ResponseTypeNode
To make it consistent with RequestTypeNone, the ResponseTypeNone
should not write any response header or HTTP status code. It will be
handled manually by [Endpoint.Call].
=== New features
* lib/play: new package for formatting and running Go code
Package play provides callable APIs and HTTP handlers to format and
run Go code, similar to Go playground, but using HTTP instead of
WebSocket.
* lib/http: add Server method to register handler by function
The RegisterHandleFunc register a pattern with a handler, similar to
[http.ServeMux.HandleFunc]. The pattern follow the Go 1.22 format:
[METHOD] PATH
The METHOD is optional, default to GET. The PATH must not contains
the domain name and space. Unlike standard library, variable in PATH
is read using ":var" not "{var}". This endpoint will accept any
content type and return the body as is; it is up to the handler to
read and set the content type and the response headers.
If the METHOD and/or PATH is already registered it will panic.
* lib/bytes: add function AppendInt64 and AppendUint64
The AppendInt64 append an int64 value into slice of byte. The
AppendUint64 append an uint64 value into slice of byte.
|
|
|
|
Package play provides callable APIs and HTTP handlers to format and run
Go code, similar to Go playground, but using HTTP instead of WebSocket.
|
|
The RegisterHandleFunc register a pattern with a handler, similar to
[http.ServeMux.HandleFunc].
The pattern follow the Go 1.22 format:
[METHOD] PATH
The METHOD is optional, default to GET.
The PATH must not contains the domain name and space.
Unlike standard library, variable in PATH is read using ":var" not
"{var}".
This endpoint will accept any content type and return the body as is;
it is up to the handler to read and set the content type and the response
headers.
If the METHOD and/or PATH is already registered it will panic.
|
|
To make consistent with RequestTypeNone, the
ResponseTypeNone should not write any response header or
HTTP status code.
It will be handled manually by [Endpoint.Call].
|
|
The AppendInt64 append an int64 value into slice of byte.
The AppendUint64 append an uint64 value into slice of byte.
|
|
|
|
|
|
From now on, any new or changes to files will use SDPX license format
in the file header.
|
|
This is the second time the golangci-lint does not work using go tip.
We also found that running golangci-lint on VM with 8GB cause the program
crash with out of memory.
|
|
=== Breaking changes
* lib/sql: replace [http.FileSystem] with [memfs.MemFS]
Accepting the [http.FileSystem] means that the parameter can receive
an instance of [embed.FS], but in most cases, it will fail.
Case example, when we embed SQL files for migration under
"db/migration" using the "go:embed" directive,
//go:embed db/migration/*.sql
var DBMigrationFS embed.FS
and then call the [Migrate] function, it will not find any ".sql"
files inside the "/" directory because the files is stored under
"db/migration/" prefix (also there is no "/" when using embed.FS).
=== Chores
* lib/memfs: document the comparison with "go:embed" directive
Compare it to "go:embed", the memfs package is more flexible and
portable. Currently, we found three disadvantages of using "go:embed",
- The "go:embed" only works if files or directory to be embedded is
in the same parent directory.
- Accessing the embedded file require the original path.
- No development mode.
None of those limitation affected the memfs package.
|
|
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.
|
|
|
|
Accepting the [http.FileSystem] means that the parameter can receive an
instance of [embed.FS], but in most cases, it will fail.
Case example, when we embed SQL files for migration under
"db/migration" using the "go:embed" directive,
//go:embed db/migration/*.sql
var DBMigrationFS embed.FS
and then call the [Migrate] function, it will not found any ".sql" files
inside the "/" directory because the files is stored under
"db/migration/" prefix (also there is no "/" when using embed.FS).
|
|
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.
|
|
== New features
* cmd/emaildecode: CLI to decode email body to plain text
The emaildecode accept file as input. If the email header contains
content-transfer-encoding with value quoted-printable or base64, it will
decode the message body and print it to stdout as plain text.
== Bug fixes
* lib/memfs: another fix for refresh
In previous commit we use wrong condition when handling directory
"." as Root.
== Enhancements
* lib/email: allow message that end lines with LF only
Although, a message from network must end with CRLF, a message from
(another) client may have been sanitized and end with LF only.
* lib/email: decode the message body based on content-transfer-encoding
After the header and body has been parsed, if the header contains
Content-Transfer-Encoding, we decode the body into its local formats.
Currently supported encoding is "quoted-printable" and "base64".
== Others
* lib/email: export the Header fields
By exporting the fields, this allow the caller to filter or manage
the field manually.
* _doc: add partial note and summary for RFC 2183
The RFC 2183 is define Content-Disposition header field in the
internet message.
* lib/ini: mention that marshaling []byte does not supported
Due to "byte" is considered as "uint8" during reflection, we cannot
tell whether the value is slice of byte of slice of number with type
uint8.
|