Skip to content

Commit 629e4ea

Browse files
fix linter warnings
1 parent c0743a9 commit 629e4ea

6 files changed

Lines changed: 21 additions & 21 deletions

File tree

checks/tmdl.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import "strings"
44

55
const tabWidth = 4
66

7-
// Find the first line whose left-trimmed text has prefix `query`, and return the
8-
// "item block": that line plus following lines until the next non-empty line with
9-
// indent <= the matched line's indent
7+
// ExtractTmdlBlock finds the first line whose left-trimmed text has prefix `query` and
8+
// returns the "item block": that line plus following lines until the next non-empty
9+
// line with indent <= the matched line's indent.
1010
func ExtractTmdlBlock(input, query string) string {
1111
trimmedQuery := strings.TrimSpace(query)
1212
if trimmedQuery == "" {

client/auth.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ type CurrentUserResponse struct {
2525
}
2626

2727
func FetchAccessToken() (*LoginResponse, error) {
28-
api_url := viper.GetString("api_url")
28+
apiURL := viper.GetString("api_url")
2929
client := &http.Client{}
30-
r, err := http.NewRequest("POST", api_url+"/v1/auth/refresh", bytes.NewBuffer([]byte{}))
30+
r, err := http.NewRequest("POST", apiURL+"/v1/auth/refresh", bytes.NewBuffer([]byte{}))
3131
r.Header.Add("X-Refresh-Token", viper.GetString("refresh_token"))
3232
if err != nil {
3333
return nil, err
@@ -53,13 +53,13 @@ func FetchAccessToken() (*LoginResponse, error) {
5353
}
5454

5555
func LoginWithCode(code string) (*LoginResponse, error) {
56-
api_url := viper.GetString("api_url")
56+
apiURL := viper.GetString("api_url")
5757
req, err := json.Marshal(LoginRequest{Otp: code})
5858
if err != nil {
5959
return nil, err
6060
}
6161

62-
resp, err := http.Post(api_url+"/v1/auth/otp/login", "application/json", bytes.NewReader(req))
62+
resp, err := http.Post(apiURL+"/v1/auth/otp/login", "application/json", bytes.NewReader(req))
6363
if err != nil {
6464
return nil, err
6565
}
@@ -116,9 +116,9 @@ func fetchWithAuth(method string, url string) ([]byte, error) {
116116
}
117117

118118
func fetchWithAuthAndPayload(method string, url string, payload []byte) ([]byte, int, error) {
119-
api_url := viper.GetString("api_url")
119+
apiURL := viper.GetString("api_url")
120120
client := &http.Client{}
121-
r, err := http.NewRequest(method, api_url+url, bytes.NewBuffer(payload))
121+
r, err := http.NewRequest(method, apiURL+url, bytes.NewBuffer(payload))
122122
if err != nil {
123123
return nil, 0, err
124124
}

client/lessons.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ type HTTPRequestResponseVariable struct {
112112
Path string
113113
}
114114

115-
// Only one of these fields should be set
115+
// HTTPRequestTest should have only one field set
116116
type HTTPRequestTest struct {
117117
StatusCode *int
118118
BodyContains *string

cmd/login.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ var loginCmd = &cobra.Command{
4747
fmt.Print("Welcome to the Boot.dev CLI!\n\n")
4848
}
4949

50-
loginUrl := viper.GetString("frontend_url") + "/cli/login"
50+
loginURL := viper.GetString("frontend_url") + "/cli/login"
5151

52-
fmt.Println("Please navigate to:\n" + loginUrl)
52+
fmt.Println("Please navigate to:\n" + loginURL)
5353

5454
inputChan := make(chan string)
5555

@@ -68,7 +68,7 @@ var loginCmd = &cobra.Command{
6868
go func() {
6969
browser.Stdout = nil
7070
browser.Stderr = nil
71-
browser.OpenURL(loginUrl)
71+
browser.OpenURL(loginURL)
7272
}()
7373

7474
// race the web server against the user's input
@@ -123,8 +123,8 @@ func startHTTPServer(inputChan chan string) {
123123
}
124124

125125
handleRedirect := func(w http.ResponseWriter, r *http.Request) {
126-
loginUrl := viper.GetString("frontend_url") + "/cli/login"
127-
http.Redirect(w, r, loginUrl, http.StatusSeeOther)
126+
loginURL := viper.GetString("frontend_url") + "/cli/login"
127+
http.Redirect(w, r, loginURL, http.StatusSeeOther)
128128
}
129129

130130
http.Handle("POST /submit", cors(http.HandlerFunc(handleSubmit)))

cmd/logout.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ import (
1111
)
1212

1313
func logout() {
14-
api_url := viper.GetString("api_url")
14+
apiURL := viper.GetString("api_url")
1515
client := &http.Client{}
1616
// Best effort - logout should never fail
17-
r, _ := http.NewRequest("POST", api_url+"/v1/auth/logout", bytes.NewBuffer([]byte{}))
17+
r, _ := http.NewRequest("POST", apiURL+"/v1/auth/logout", bytes.NewBuffer([]byte{}))
1818
r.Header.Add("X-Refresh-Token", viper.GetString("refresh_token"))
1919
client.Do(r)
2020

cmd/root.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,12 +172,12 @@ func requireAuth(cmd *cobra.Command, args []string) {
172172
}
173173
}
174174

175-
access_token := viper.GetString("access_token")
176-
promptLoginAndExitIf(access_token == "")
175+
accessToken := viper.GetString("access_token")
176+
promptLoginAndExitIf(accessToken == "")
177177

178178
// We only refresh if our token is getting stale.
179-
last_refresh := viper.GetInt64("last_refresh")
180-
if time.Now().Add(-time.Minute*55).Unix() <= last_refresh {
179+
lastRefresh := viper.GetInt64("last_refresh")
180+
if time.Now().Add(-time.Minute*55).Unix() <= lastRefresh {
181181
return
182182
}
183183

0 commit comments

Comments
 (0)