{"record":{"id":"f7e019ffc3325630","repo":"golang/go","slug":"invalid-quoted-string-in-go-embed-s","errorCode":null,"errorMessage":"invalid quoted string in //go:embed: %s","messagePattern":"invalid quoted string in //go:embed: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/compile/internal/noder/noder.go","lineNumber":412,"sourceCode":"\tfor args = strings.TrimSpace(args); args != \"\"; args = strings.TrimSpace(args) {\n\t\tvar path string\n\tSwitch:\n\t\tswitch args[0] {\n\t\tdefault:\n\t\t\ti := len(args)\n\t\t\tfor j, c := range args {\n\t\t\t\tif unicode.IsSpace(c) {\n\t\t\t\t\ti = j\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tpath = args[:i]\n\t\t\targs = args[i:]\n\n\t\tcase '`':\n\t\t\ti := strings.Index(args[1:], \"`\")\n\t\t\tif i < 0 {\n\t\t\t\treturn nil, fmt.Errorf(\"invalid quoted string in //go:embed: %s\", args)\n\t\t\t}\n\t\t\tpath = args[1 : 1+i]\n\t\t\targs = args[1+i+1:]\n\n\t\tcase '\"':\n\t\t\ti := 1\n\t\t\tfor ; i < len(args); i++ {\n\t\t\t\tif args[i] == '\\\\' {\n\t\t\t\t\ti++\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif args[i] == '\"' {\n\t\t\t\t\tq, err := strconv.Unquote(args[:i+1])\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, fmt.Errorf(\"invalid quoted string in //go:embed: %s\", args[:i+1])\n\t\t\t\t\t}\n\t\t\t\t\tpath = q\n\t\t\t\t\targs = args[i+1:]","sourceCodeStart":394,"sourceCodeEnd":430,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/compile/internal/noder/noder.go#L394-L430","documentation":"Returned by the //go:embed pattern parser when a backtick-quoted pattern is opened but never closed. The parser finds the opening backtick, searches args[1:] for a matching backtick, and if none is found treats the rest of the line as an invalid quoted string.","triggerScenarios":"A //go:embed directive contains a backtick-quoted pattern with no closing backtick, e.g. //go:embed `pattern. The strings.Index for the closing backtick returns -1 (i<0) and the error reports the entire remaining args.","commonSituations":"Hand-editing //go:embed directives and forgetting the closing backtick; copy-paste truncating the line; an editor autocompleting only the opening backtick.","solutions":["Add the closing backtick to the pattern: //go:embed `pattern`.","Prefer unquoted patterns (//go:embed pattern) unless the path contains spaces, in which case use backtick-quoted segments and close both ends.","Run gofmt which will surface the malformed directive at edit time."],"exampleFix":"// before\n //go:embed `assets/*.html\n // after\n //go:embed `assets/*.html`","handlingStrategy":"validation","validationCode":"// Validate backtick-quoted //go:embed patterns before compiling.\nfor _, p := range strings.Split(line, \"`\") {\n    _ = p\n}\nif open := strings.Count(rest, \"`\"); open%2 != 0 {\n    return fmt.Errorf(\"unbalanced backticks in //go:embed\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always close backtick-quoted embed patterns.","Prefer unquoted patterns; quote only when a path contains spaces.","Run gofmt/gopls which flag malformed //go:embed directives."],"tags":["go-compiler","go-embed","parser","directives"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:17:08.281Z"}