all: resync with master

This commit is contained in:
Ainar Garipov
2024-09-30 20:17:20 +03:00
parent c7d8b9ede1
commit 8cb5781770
153 changed files with 28633 additions and 27594 deletions

View File

@@ -4,8 +4,10 @@
package main
import (
"context"
"encoding/json"
"fmt"
"log/slog"
"net/http"
"net/url"
"os"
@@ -14,10 +16,13 @@ import (
"text/template"
"time"
"github.com/AdguardTeam/golibs/log"
"github.com/AdguardTeam/golibs/logutil/slogutil"
)
func main() {
ctx := context.Background()
l := slogutil.New(nil)
urlStr := "https://adguardteam.github.io/HostlistsRegistry/assets/services.json"
if v, ok := os.LookupEnv("URL"); ok {
urlStr = v
@@ -33,7 +38,7 @@ func main() {
resp, err := c.Get(urlStr)
check(err)
defer log.OnCloserError(resp.Body, log.ERROR)
defer slogutil.CloseAndLog(ctx, l, resp.Body, slog.LevelError)
if resp.StatusCode != http.StatusOK {
panic(fmt.Errorf("expected code %d, got %d", http.StatusOK, resp.StatusCode))
@@ -64,7 +69,7 @@ func main() {
0o644,
)
check(err)
defer log.OnCloserError(f, log.ERROR)
defer slogutil.CloseAndLog(ctx, l, f, slog.LevelError)
err = tmpl.Execute(f, hlSvcs)
check(err)