这是indexloc提供的服务,不要输入任何密码
Skip to content

add custom template  #187

@neocortexplus

Description

@neocortexplus

hello hope you doing well,

i want to create a custom template so simple template to return the output result in addition of the pass faill tests result ,

i create a simple_template.go and put it in the directory templates but when i run i got some weird messages , i didn't find any place to find a tutorial to help me to create my template,


 {{ define "Test" }}
func Test_{{ .Name }}(t *testing.T) {
    type args struct {
        {{- range .Fields }}
        {{ .Name }} {{ .Type }}
        {{- end }}
    }
    tests := []struct {
        name string
        args args
        want {{ .ResultType }}
    }{
        // TODO: Add test cases here.
    }
    for _, tt := range tests {
        t.Run(tt.name, func(t *testing.T) {
            got := {{ .Name }}({{ range $index, $element := .Fields }}{{ if $index }}, {{ end }}tt.args.{{ $element.Name }}{{ end }})
            if got != tt.want {
                t.Errorf("{{ .Name }}() got = %v, want %v", got, tt.want)
            }
        })
    }
}
{{ end }}

root@07598207c071:/home# ls templates/
templates.go
root@07598207c071:/home# gotests -w -only combineIntegerArrays -template_dir /home/templates/ .
output.Process: render.Header: template: no template "header" associated with template "render"

is there any solution to apply .
thanks in advance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions