Skip to content

text/template: illegal number syntax: "-" #30948

@bep

Description

@bep
package main

import (
	"log"
	"text/template"
)

func main() {
	_, err := template.New("").Parse(`{{- .Foo  -}}`)
	if err != nil {
		log.Fatal(err)
	}
}

Fails with:

template: :1: illegal number syntax: "-"

https://play.golang.org/p/VC7LYAI34HU

There is an extra space after .Foo, which is an easy "mistake" to make (I just did), and not always obvious to spot, esp. since there is only a line number in the error message.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions