-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathghissue.go
More file actions
36 lines (27 loc) · 764 Bytes
/
ghissue.go
File metadata and controls
36 lines (27 loc) · 764 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package ghissue
import (
"errors"
"fmt"
"net/url"
"runtime"
"strings"
)
// ErrOpenBrowser is the error returned when opening the browser fails.
var ErrOpenBrowser = errors.New("failed to open browser")
const urlTemplate = "https://github.com/%s/%s/issues/new?title=%s&body=%s"
func getURL(owner, repo, title, body string) string {
title = url.QueryEscape(title)
body = url.QueryEscape(body)
return fmt.Sprintf(urlTemplate, owner, repo, title, body)
}
func getStackTrace() string {
b := make([]byte, 1024)
n := runtime.Stack(b, false)
trace := string(b[:n])
// cut of first 5 lines of stack trace
lines := strings.Split(trace, "\n")
lines = lines[5:]
trace = strings.Join(lines, "\n")
trace = strings.TrimRight(trace, "\n")
return trace
}