Code generator to help implement the visitor pattern.

mkvisitor

Given

package example

type (
	Node struct{}
	Leaf struct{}
)

run mkvisitor -type "Node,Leaf" then generate

package example

import "fmt"

type Visitor interface {
	VisitNode(*Node)
	VisitLeaf(*Leaf)
}

func (s *Node) Accept(v Visitor) { v.VisitNode(s) }
func (s *Leaf) Accept(v Visitor) { v.VisitLeaf(s) }

type VisitorDefault struct{}

func (s *VisitorDefault) VisitNode(_ *Node) {}
func (s *VisitorDefault) VisitLeaf(_ *Leaf) {}
func VisitSwitch(visitor Visitor, v interface{}) {
	switch v := v.(type) {
	case *Node:
		visitor.VisitNode(v)
	case *Leaf:
		visitor.VisitLeaf(v)
	default:
		panic(fmt.Sprintf("VisitSwitch cannot switch %#v", v))
	}
}

in visitor_mkvisitor.go in the same directory.

Similar Resources

TiDB Mesh: Implement Multi-Tenant Keyspace by Decorating Message between Components

TiDB Mesh: Implement Multi-Tenant Keyspace by Decorating Message between Components

TiDB Mesh: Implement Multi-Tenant Keyspace by Decorating Message between Compone

Jan 11, 2022

Go-indexeddb - This expirement will attempt to implement IndexedDB features for Go

go-indexeddb This expirement will attempt to implement IndexedDB features for Go

May 29, 2022

DepCharge is a tool designed to help orchestrate the execution of commands across many directories at once.

DepCharge DepCharge is a tool that helps orchestrate the execution of commands across the many dependencies and directories in larger projects. It als

Sep 27, 2022

Dredger is a utility to help convert helm charts to Terraform modules using kubernetes provider.

dredger Dredger is a utility to help convert helm charts to Terraform modules using kubernetes provider. Dredger is made of dark magic and cannot full

Aug 25, 2022

Terraform provider to help with various AWS automation tasks (mostly all that stuff we cannot accomplish with the official AWS terraform provider)

Terraform provider to help with various AWS automation tasks (mostly all that stuff we cannot accomplish with the official AWS terraform provider)

terraform-provider-awsutils Terraform provider for performing various tasks that cannot be performed with the official AWS Terraform Provider from Has

Dec 8, 2022

GitOops is a tool to help attackers and defenders identify lateral movement and privilege escalation paths in GitHub organizations by abusing CI/CD pipelines and GitHub access controls.

GitOops is a tool to help attackers and defenders identify lateral movement and privilege escalation paths in GitHub organizations by abusing CI/CD pipelines and GitHub access controls.

GitOops is a tool to help attackers and defenders identify lateral movement and privilege escalation paths in GitHub organizations by abusing CI/CD pipelines and GitHub access controls.

Jan 2, 2023

Hackathon project with intent to help based on heuristics for aks cluster upgrades.

Hackathon project with intent to help based on heuristics for aks cluster upgrades.

AKS-Upgrade-Doctor AKS Upgrade Doctor is a client side, self-help diagnostic tool designed to identify and detect possible issues that cause upgrade o

Sep 20, 2022

Help my family picking secret santas without having a person beeing involved

secret-santa This is a small project I wrote to help my family picking secret santas without having a person beeing involved. This way noone is left o

Nov 6, 2021

Help developer to sync between local file and remote apollo portal web since portal web is so messy to use

apollo-synchronizer Help developer to sync between local file and remote apollo portal web since portal web is so messy to use Features download names

Oct 27, 2022
Related tags
Open Source runtime tool which help to detect malware code execution and run time mis-configuration change on a kubernetes cluster
Open Source runtime tool which help to detect malware code execution and run time mis-configuration change on a kubernetes cluster

Kube-Knark Project Trace your kubernetes runtime !! Kube-Knark is an open source tracer uses pcap & ebpf technology to perform runtime tracing on a de

Sep 19, 2022
tfa is a 2fa cli tool that aims to help you to generate 2fa code on CI/CD pipelines.

tfa tfa is 2fa cli tool that aim to help you to generate 2fa code on CI/CD pipelines. You can provide secret with stdin or flag. Install brew install

Nov 27, 2022
sail is an operation framework based on Ansible/Helm. sail follows the principles of Infrastructure as Code (IaC), Operation as Code (OaC), and Everything as Code. So it is a tool for DevOps.

sail 中文文档 sail is an operation framework based on Ansible/Helm. sail follows the principles of Infrastructure as Code (IaC), Operation as Code (OaC),a

Dec 16, 2021
The Operator Pattern, in Nomad

Nomad Operator Example Repostiory to go along with my The Operator Pattern in Nomad blog post. Usage If you have tmux installed, you can run start.sh

May 12, 2022
Package create provides a generic option pattern for creating new values of any type

create Package create provides a generic option pattern for creating new values

Dec 30, 2021
A kubernetes operator demo generated by code-generator, it only watches cr's events

intro a small operator demo which only watches car cr's events. environment: ubuntu-20.04-amd64 k3s-1.21 docker-20.10.7 go-1.17 tools code-generator d

Dec 13, 2021
Using Go to implement CobaltStrike's Beacon
Using Go to implement CobaltStrike's Beacon

Geacon 本项目仅限于安全研究和教学,严禁用于非法用途! Usage 修改core/config.go中的配置信息 设置平台和架构set "GOOS=linux" && set "GOARCH=amd64" 编译生成go build -ldflags="-s -w" main.go Screen

Nov 15, 2022
Go implement for Genshin Gacha Export

README Build on Windows 执行命令 env GOOS=windows GOARCH=amd64 go build 测试在 windows 11 上通过 使用 确保在原神游戏中打开一次祈愿记录. 然后双击运行 GenshinGachaExport.exe. 它将会在当前目录下生成

Apr 6, 2022
The CLI tool glueing Git, Docker, Helm and Kubernetes with any CI system to implement CI/CD and Giterminism
The CLI tool glueing Git, Docker, Helm and Kubernetes with any CI system to implement CI/CD and Giterminism

___ werf is an Open Source CLI tool written in Go, designed to simplify and speed up the delivery of applications. To use it, you need to describe the

Jan 4, 2023
Edge Orchestration project is to implement distributed computing between Docker Container enabled devices.
Edge Orchestration project is to implement distributed computing between Docker Container enabled devices.

Edge Orchestration Introduction The main purpose of Edge Orchestration project is to implement distributed computing between Docker Container enabled

Dec 17, 2021