func encode(source string, targets []string, output string, includePaths []string, experimental bool) error {
	files, err := parseInput(source)  
	if err != nil {
		return err
	}
	include := map[string]*ast.File{}
	for _, i := range includePaths {
		files, err := parseInput(i)
		if err != nil {
			return err
		}
		for k, v := range files {
			include[k] = v
		}
	}
	var packName string
	for _, file := range files {
		packName = file.Name.Name
	}
	e := &env{
		include:  include,
		source:   source,
		files:    files,
		objs:     map[string]*Value{},
		packName: packName,
		targets:  targets,
	}
	if err := e.generateIR(); err != nil {  
		return err
	}
	var out map[string]string
	if output == "" {
		out, err = e.generateEncodings(experimental)
	} else {
		out, err = e.generateOutputEncodings(output, experimental)
	}
	if err != nil {
		panic(err)
	}
	if out == nil {
		panic("No files to generate")
	}
	for name, str := range out {
		output := []byte(str)
		output, err = format.Source(output)
		if err != nil {
			return err
		}
		if err := ioutil.WriteFile(name, output, 0644); err != nil {
			return err
		}
	}
	return nil
}
The SSZ code generation works in three steps:
1. Parse the Go input with the go/parser library to generate an AST representation.
2. Convert the AST into an Internal Representation (IR) to describe the structs and fields
using the Value object.
3. Use the IR to print the encoding functions
package main
import (
	"bytes"
	"crypto/sha256"
	"encoding/hex"
	"flag"
	"fmt"
	"go/ast"
	"go/format"
	"go/parser"
	"go/token"
	"io/ioutil"
	"os"
	"path/filepath"
	"reflect"
	"sort"
	"strconv"
	"strings"
	"text/template"
)
const bytesPerLengthOffset = 4
func main() {
	var source string
	var objsStr string
	var output string
	var include string
	var experimental bool
	flag.StringVar(&source, "path", "", "")
	flag.StringVar(&objsStr, "objs", "", "")
	flag.StringVar(&output, "output", "", "")
	flag.StringVar(&include, "include", "", "")
	flag.BoolVar(&experimental, "experimental", false, "")
	flag.Parse()
	targets := decodeList(objsStr)
	includeList := decodeList(include)
	if err := encode(source, targets, output, includeList, experimental); err != nil {
		fmt.Printf("[ERR]: %v\n", err)
		os.Exit(1)
	}
}
func decodeList(input string) []string {
	if input == "" {
		return []string{}
	}
	return strings.Split(strings.TrimSpace(input), ",")
}