Skip to content

Instantly share code, notes, and snippets.

@haya14busa
Created February 4, 2017 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save haya14busa/95a5ad6c1b2cfff369ff726b47967c19 to your computer and use it in GitHub Desktop.
Save haya14busa/95a5ad6c1b2cfff369ff726b47967c19 to your computer and use it in GitHub Desktop.
ignore missing ','
diff --git a/imports/imports.go b/imports/imports.go
index 67573f4..32db0ca 100644
--- a/imports/imports.go
+++ b/imports/imports.go
@@ -124,6 +124,11 @@ func parse(fset *token.FileSet, filename string, src []byte, opt *Options) (*ast
if err == nil {
return file, nil, nil
}
+
+ if err != nil && strings.Contains(err.Error(), "missing ',' before newline in composite literal") {
+ return file, nil, nil
+ }
+
// If the error is that the source file didn't begin with a
// package line and we accept fragmented input, fall through to
// try as a source fragment. Stop and return on any other error.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment