File tree Expand file tree Collapse file tree 1 file changed +12
-17
lines changed Expand file tree Collapse file tree 1 file changed +12
-17
lines changed Original file line number Diff line number Diff line change @@ -218,24 +218,19 @@ parsePackageVersion lexify = parseSemOrPseudo <|> parseNonCanonical
218
218
219
219
gomodParser :: Parser Gomod
220
220
gomodParser = do
221
+ let emptyGoMod = do
222
+ eof
223
+ pure (" " , [] )
224
+ let nonEmptyGoMod = do
225
+ _ <- lexeme (chunk " module" )
226
+ name <- modulePath
227
+ _ <- scn
228
+ statements <- many (statement <* scn)
229
+ eof
230
+ pure (name, statements)
231
+
221
232
_ <- scn
222
- (name, statements) <-
223
- choice
224
- [ -- Non-empty go.mod file
225
- ( do
226
- _ <- lexeme (chunk " module" )
227
- name <- modulePath
228
- _ <- scn
229
- statements <- many (statement <* scn)
230
- eof
231
- pure (name, statements)
232
- )
233
- , -- Empty go.mod file
234
- ( do
235
- eof
236
- pure (" " , [] )
237
- )
238
- ]
233
+ (name, statements) <- choice [nonEmptyGoMod, emptyGoMod]
239
234
240
235
let statements' = concat statements
241
236
You can’t perform that action at this time.
0 commit comments