相关疑难解决方法(0)

带开关和ForEach的Golang模板

我需要从golang程序创建bash.sh文件,该文件应该执行以下操作:

创建的ForEach上依赖回路和读取的类型和根据打印类型不同的回波消息(命令)我需要它一起工作开关type与Golang的依赖性的

例如以下内容

对于每个依赖项,添加echo的类型消息

#!/bin/bash
for a in $(dependencies.type) 
  echo $runner  //from type 
done
Run Code Online (Sandbox Code Playgroud)

我做的是以下哪些不起作用

  1. 依赖关系类型"runner1"的想法(参见依赖结构实例中的type属性值)我需要运行几个命令,对于"runner2"我需要运行几个不同的命令
  2. 上面的那些命令(比如echo1的echo api1)应该写在我需要从模板创建的bash.script中

包主

import (
    "fmt"
    "log"
    "text/template"
    "gopkg.in/yaml.v2"
    "os"
)

type File struct {
    TypeVersion string `yaml:"_type-version"`
    Dependency  []Dependency
}

type Dependency struct {
    Name    string
    Type    string
    CWD     string
    Install []Install
}

type Install map[string]string

var data = `
_type-version: "1.0.0"
dependency:
  - name: ui
    type: runner …
Run Code Online (Sandbox Code Playgroud)

templates go

8
推荐指数
1
解决办法
518
查看次数

标签 统计

go ×1

templates ×1