krystal/go-runner

View on GitHub
scripts/mockgen_fix.go

Summary

Maintainability
A
0 mins
Test Coverage
package main

import (
    "fmt"
    "io"
    "os"
    "regexp"
)

var re = regexp.MustCompile(
    `(?ms)^(\/\/ Code generated by MockGen.+?Source: .+?)$` +
        `.*?` +
        `^(// Package mock_.+?)$`,
)

func main() {
    b, err := io.ReadAll(os.Stdin)
    if err != nil {
        return
    }

    result := re.ReplaceAllString(string(b), "$1\n//\n$2")

    fmt.Print(result)
}