Skip to content

switchupcb/fyneform

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Generate a Fyne GUI Form based on Go types

License

Use Fyneform to stop wasting time developing Fyne GUI Forms based on Go types.

What is Fyneform?

Fyneform is a code generator which generates Fyne GUI form code based on Go types without adding a dependency to your project.

Table of Contents

Topic Category
Using Fyneform 1. Define Go types
2. Configure Copygen
3. Generate Fyne Forms
View Output

How do you use Fyneform?

This demonstration (at example) generates a Fyneform for an Account Go type.

Step 1. Define Go types

Go types are defined in a file.

./domain/domain.go

// Account represents a user's account.
type Account struct {
    ID int
    Username string
    Password string
    Name string
}

Step 2. Configure Copygen

Copygen is used to generate code based on Go types.

1) example/setup/copygen/setup.yml

Configure the setup.yml file.

# Define where the code is generated.
generated:
  setup: ./setup.go
  output: ../../app/fyneform/fyneform.go
  template: ../fyneform/generate.go

matcher:
    skip: true

2) example/setup/copygen/setup.go

Configure the setup.go file.

package fyneform

import (
	"github.com/fyneform/example/app/domain"
)

// Copygen defines the functions that are generated.
type Copygen interface {
	// AccountForm represents the generated functions name which returns a &widget.Form.
	//
	// You can include multiple Go types (e.g., `domain.Account`) in a single form.
	//
	// WARNING: Do not define Go types with a pointer.
	AccountForm(domain.Account)
}

3) example/setup/fyneform/generate.go

Configure the generator template (e.g., copy the file).

You can modify this file to customize how a form is generated.

Step 3. Generate Fyne Forms

Install Copygen.

go install github.com/switchupcb/copygen@latest

Run the executable in a command line.

cd example/app
copygen -yml ../setup/copygen/setup.yml

You must execute this demonstration from the example/app directory so the Go types defined in the example's Go module (i.e., github.com/fyneform/example/app) are resolved correctly by the Go module system.

Output

Fyneform Example Application Output

About

Fyneform is a code generator which generates Fyne GUI Forms based on Go types.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages