Openstatus www.openstatus.dev

๐Ÿ”ฅ golang improvments (#992)

* ๐Ÿ”ฅ golang improvments

* ๐ŸŸข fix build

* ๐ŸŸข fix build

* ๐ŸŸข fix build

authored by

Thibault Le Ouay and committed by
GitHub
cc4dba94 a9c03d8e

+25 -5
+7
.vscode/settings.json
··· 21 21 }, 22 22 "[ignore]": { 23 23 "editor.defaultFormatter": "foxundermoon.shell-format" 24 + }, 25 + "go.lintTool": "golangci-lint", 26 + "go.lintFlags": ["--fast"], 27 + "gopls": { 28 + "ui.diagnostic.analyses": { 29 + "fieldalignment": true 30 + } 24 31 } 25 32 }
+1 -1
apps/checker/cmd/main.go
··· 309 309 310 310 headersAsString, err := json.Marshal(r.Headers) 311 311 if err != nil { 312 - return nil 312 + return err 313 313 } 314 314 315 315 tbData := PingResponse{
+7 -3
apps/checker/update.go
··· 24 24 url := "https://openstatus-api.fly.dev/updateStatus" 25 25 basic := "Basic " + os.Getenv("CRON_SECRET") 26 26 payloadBuf := new(bytes.Buffer) 27 - json.NewEncoder(payloadBuf).Encode(updateData) 28 - req, err := http.NewRequestWithContext(ctx, http.MethodPost, url, payloadBuf) 27 + if err := json.NewEncoder(payloadBuf).Encode(updateData); err != nil { 28 + log.Ctx(ctx).Error().Err(err).Msg("error while updating status") 29 + return 30 + } 31 + req, _ := http.NewRequestWithContext(ctx, http.MethodPost, url, payloadBuf) 29 32 req.Header.Set("Authorization", basic) 30 33 req.Header.Set("Content-Type", "application/json") 31 34 32 35 client := &http.Client{Timeout: time.Second * 10} 33 - if _, err = client.Do(req); err != nil { 36 + if _, err := client.Do(req); err != nil { 34 37 log.Ctx(ctx).Error().Err(err).Msg("error while updating status") 35 38 } 39 + defer req.Body.Close() 36 40 // Should we add a retry mechanism here? 37 41 }
+2
pnpm-lock.yaml
··· 7180 7180 7181 7181 inflight@1.0.6: 7182 7182 resolution: {integrity: sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==} 7183 + deprecated: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful. 7183 7184 7184 7185 inherits@2.0.4: 7185 7186 resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==} ··· 9130 9131 9131 9132 rimraf@3.0.2: 9132 9133 resolution: {integrity: sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==} 9134 + deprecated: Rimraf versions prior to v4 are no longer supported 9133 9135 hasBin: true 9134 9136 9135 9137 rollup-plugin-inject@3.0.2:
+8 -1
turbo.json
··· 11 11 "DATABASE_URL", 12 12 "TINY_BIRD_API_KEY", 13 13 "NODE_ENV", 14 - "VERCEL_URL" 14 + "VERCEL_URL", 15 + "TEAM_ID_VERCEL", 16 + "PROJECT_ID_VERCEL", 17 + "STRIPE_SECRET_KEY", 18 + "UNKEY_TOKEN", 19 + "UNKEY_API_ID", 20 + "UPSTASH_REDIS_REST_URL", 21 + "UPSTASH_REDIS_REST_TOKEN" 15 22 ], 16 23 "outputs": [".next/**", "!.next/cache/**"] 17 24 },