Generate new modules

The widgets that you see on the screen are displayed using modules. To make it easier to create new modules there is a generator which creates a stub (an empty module). The Go package generators contains generator scripts for different types of widgets.

Prerequisites

Before you can generate new modules, you’ll need to have:

New TextWidgets

You can run go generate -run=text to create a new widget called NewTextWidget. You can change the name of the generated widget by setting an environment variable called WTF_WIDGET_NAME.

For example, to generate a new widget called MySuperAwesomeWidget on macOs or linux, the command would be:

# as a single line
WTF_WIDGET_NAME=MySuperAwesomeWidget go generate -run=text
# setting the name separately
export WTF_WIDGET_NAME=MySuperAwesomeWidget
go generate -run=text

The equivalent using Windows PowerShell would be

$env:WTF_WIDGET_NAME = "MySuperAwesomeWidget"
go generate -run=text

The new widget is generated using the template in textwidget.tpl

Source Code

wtf/generator/