Last active
October 17, 2015 12:42
-
-
Save maddygoround/90eb728686b26c03ba24 to your computer and use it in GitHub Desktop.
Find Error code from the given error in golang
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ("regexp" | |
"errors" | |
"fmt" | |
) | |
var errExtract = regexp.MustCompile(`Err (\d+)`) | |
func main(){ | |
customErr := errors.New("Err 1024 ; sql must use 3 rows but define 4 in scan") | |
match := errExtract.FindStringSubmatch(customErr.Error()) | |
fmt.Print(match) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment