Skip to content

Commit

Permalink
fix bug with missing new line
Browse files Browse the repository at this point in the history
  • Loading branch information
junedev committed Jul 16, 2019
1 parent 9f3ef40 commit 5672d7b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion mockgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ func calcResultMock(existingMock string, newMock string) (string, error) {
bodyFunctions := combineFunctions(existingFunctions, newFunctions)
bodyStr := ""
for _, fn := range bodyFunctions {
bodyStr += fn.fullFunction
bodyStr += fn.fullFunction + "\n\n"
}
bodyStr = strings.TrimSuffix(bodyStr, "\n")
return newPreamble + bodyStr, nil
Expand Down Expand Up @@ -275,6 +275,10 @@ func extractBlocksAndPreamble(input string) ([]functionBlock, string, error) {

blocks := []functionBlock{}
for _, fn := range functions {
if strings.HasSuffix(fn, "\n\n") {
fn = strings.TrimRight(fn, "\n")
}

matches := signatureRegex.FindStringSubmatch(fn)
if len(matches) < 2 {
return nil, "", errors.New("failed to find function signature: " + fn)
Expand Down

0 comments on commit 5672d7b

Please sign in to comment.