Using Wharf for automatic porting
You can use Wharf to automatically fix build errors caused by packages or modules that don't support z/OS® by investigating type checking errors and updating module dependencies or retagging files to include missing function, variable, constant, or type definitions.
- Port existing packages or modules in a workspace
- Port dependencies of modules (dependencies will be moved inside workspace)
- Provide insights into possible issues with the package or module
- Make edits and run commands to ensure the package or module can be installed on z/OS without error
Usage
go build with the following
command:wharf [-d] [-v] [-t] [-tags] <packages>Wharf only supports
executing within a workspace, which means operating similarly to go build
-mod=readonly with the following considerations:- Must be inside a Go workspace (initialize one in your current folder by running
go work init) - The package or module to port must exist inside a workspace
Flag
- -n
- Dry-run mode; disables edits, script will only make suggestions
- -t
- Run unit tests found in packages or modules that were altered and output their result (ignored if in dry-run mode)
- -v
- Enable verbose output
Understanding the main porting process of Wharf
Wharf works by first loading the environment using go list and gathering
information related to the package or module structures. This occurs in
internal/packages, which acts almost as a special purpose compiler front-end
implementation.
Type-checking occurs after the loading. Packages or modules are type checked until the first error occurs, at which the porting process begins for that package.
Packages or modules are ported based on the structure of the dependency tree. Packages or modules that are higher up in the dependency tree, that is those have fewer levels of sub-dependencies, will be ported first.
Basic steps using Wharf for porting modules
go install github.com/zosopentools/wharf@latestIf you're using the default GOPATH, then make sure ~/go/bin is on your PATH.
- Create a directory to serve as your workspace and change directory to that
workspace.
mkdir workspace cd workspace - Execute
go work initto initialize the workspace. - Clone the module you wish to port:
git clone <url of module> - Add the module to the workspace:
go work use ./<module name> - Port the module with the Wharf tool:
wharf ./<module name>/... - If no error occurs, execute
go install ./<module name>/...to install the module and all its sub modules.
For details, see Using Wharf for porting applications.