func (v *VlanEntity) SetTrunkGroup(vid string, value []string) bool {
	var failure = false
	currentValue := strings.Split(v.Get(vid)["trunk_groups"], ",")
	diff := findDiff(value, currentValue)
	for _, name := range diff {
		if ok := v.AddTrunkGroup(vid, name); !ok {
			failure = true
		}
	}
	diff = findDiff(currentValue, value)
	for _, name := range diff {
		if ok := v.RemoveTrunkGroup(vid, name); !ok {
			failure = true
		}
	}
	return !failure
}
SetTrunkGroup Configures the list of trunk groups support on a vlan

This method handles configuring the vlan trunk group value to default
if the default flag is set to True.  If the default flag is set
to False, then this method will calculate the set of trunk
group names to be added and to be removed.

EosVersion:
4.13.7M

Args:
vid (string): The VLAN ID to configure
value (string): The list of trunk groups that should be configured
for this vlan id.

Returns:
True if the operation was successful otherwise False
package module
import (
	"fmt"
	"regexp"
	"strconv"
	"strings"
	"github.com/aristanetworks/goeapi"
)
var (
	nameRegex       = regexp.MustCompile(`(?m)(?:name\s)(.*)$`)
	stateRegex      = regexp.MustCompile(`(?m)(?:state\s)(.*)$`)
	trunkGroupRegex = regexp.MustCompile(`(?m)(?:trunk\sgroup\s)(.*)$`)
	vlansRegex      = regexp.MustCompile(`(?m)^vlan\s(\d+)$`)
)
type VlanConfig map[string]string
func (v VlanConfig) Name() string {
	return v["name"]
}
func (v VlanConfig) State() string {
	return v["state"]
}
func (v VlanConfig) TrunkGroups() string {
	return v["trunk_groups"]
}
type VlanConfigMap map[string]VlanConfig
type VlanEntity struct {
	*AbstractBaseEntity
}
func Vlan(node *goeapi.Node) *VlanEntity {
	return &VlanEntity{&AbstractBaseEntity{node}}
}
func findDiff(slice1 []string, slice2 []string) []string {
	var diff []string
	hash := map[string]int{}
	for _, val := range slice2 {
		if val == "" {
			continue
		}
		hash[val] = 1
	}
	for _, val := range slice1 {
		if val == "" {
			continue
		}
		if _, found := hash[val]; found {
			continue
		}
		diff = append(diff, val)
	}
	return diff
}
func isVlan(vlan string) bool {
	vid, _ := strconv.Atoi(vlan)
	return vid > 0 && vid < 4095
}
func (v *VlanEntity) Get(vlan string) VlanConfig {
	parent := "vlan " + vlan
	config, err := v.GetBlock(parent)
	if err != nil {
		return nil
	}
	var resource = make(VlanConfig)
	resource["name"] = v.parseName(config)
	resource["state"] = v.parseState(config)
	resource["trunk_groups"] = v.parseTrunkGroups(config)
	return resource
}
func (v *VlanEntity) GetAll() VlanConfigMap {
	config := v.Config()
	matches := vlansRegex.FindAllStringSubmatch(config, -1)
	var resources = make(VlanConfigMap)
	for _, val := range matches {
		vid := val[1]
		resources[vid] = v.Get(vid)
	}
	return resources
}
func (v *VlanEntity) GetSection(vlan string) string {
	parent := fmt.Sprintf(`vlan\s+(%s$)|(%s,.*)|(.*,%s,)|(.*,%s$)`,
		vlan, vlan, vlan, vlan)
	config, err := v.GetBlock(parent)
	if err != nil {
		return ""
	}
	return config
}
func (v *VlanEntity) parseName(config string) string {
	if config == "" {
		return ""
	}
	match := nameRegex.FindStringSubmatch(config)
	if match == nil {
		return ""
	}
	return match[1]
}
func (v *VlanEntity) parseState(config string) string {
	if config == "" {
		return ""
	}
	match := stateRegex.FindStringSubmatch(config)
	if match == nil {
		return ""
	}
	return match[1]
}
func (v *VlanEntity) parseTrunkGroups(config string) string {
	trunkGroups := []string{}
	matches := trunkGroupRegex.FindAllStringSubmatch(config, -1)
	if matches == nil {
		return ""
	}
	for _, match := range matches {
		for idx, tid := range match {
			if idx == 0 || tid == "" {
				continue
			}
			trunkGroups = append(trunkGroups, tid)
		}
	}
	return strings.Join(trunkGroups, ",")
}
func (v *VlanEntity) Create(vid string) bool {
	var commands = []string{"vlan " + vid}
	if isVlan(vid) {
		return v.Configure(commands...)
	}
	return false
}
func (v *VlanEntity) Delete(vid string) bool {
	var commands = []string{"no vlan " + vid}
	if isVlan(vid) {
		return v.Configure(commands...)
	}
	return false
}
func (v *VlanEntity) Default(vid string) bool {
	var commands = []string{"default vlan " + vid}
	if isVlan(vid) {
		return v.Configure(commands...)
	}
	return false
}
func (v *VlanEntity) ConfigureVlan(vid string, cmds ...string) bool {
	var commands = []string{"vlan " + vid}
	commands = append(commands, cmds...)
	return v.Configure(commands...)
}
func (v *VlanEntity) SetName(vid string, name string) bool {
	return v.ConfigureVlan(vid, "name "+name)
}
func (v *VlanEntity) SetNameDefault(vid string) bool {
	return v.ConfigureVlan(vid, "default name")
}
func (v *VlanEntity) SetState(vid string, value string) bool {
	if value == "" {
		return v.ConfigureVlan(vid, "no state")
	}
	return v.ConfigureVlan(vid, "state "+value)
}
func (v *VlanEntity) SetStateDefault(vid string) bool {
	return v.ConfigureVlan(vid, "default state")
}