Private
Public Access
1
0

style: format Go code with gofumpt
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing

Apply consistent formatting to Go source files using gofumpt
as required by pre-commit guidelines.
This commit is contained in:
2025-08-03 16:06:59 -07:00
parent 3e6a0f9e63
commit 2dfc355f7c
9 changed files with 21 additions and 25 deletions

View File

@@ -24,15 +24,16 @@ type ServerTotals map[string]uint64
func (s ServerQueries) Len() int {
return len(s)
}
func (s ServerQueries) Swap(i, j int) {
s[i], s[j] = s[j], s[i]
}
func (s ServerQueries) Less(i, j int) bool {
return s[i].Count > s[j].Count
}
func (d *ClickHouse) ServerAnswerCounts(ctx context.Context, serverIP string, days int) (ServerQueries, error) {
ctx, span := tracing.Tracer().Start(ctx, "ServerAnswerCounts")
defer span.End()

View File

@@ -214,13 +214,15 @@ func (d *ClickHouse) LogscoresTimeRange(ctx context.Context, serverID, monitorID
"sample_rows", func() []map[string]interface{} {
samples := make([]map[string]interface{}, 0, 3)
for i, row := range rv {
if i >= 3 { break }
if i >= 3 {
break
}
samples = append(samples, map[string]interface{}{
"id": row.ID,
"monitor_id": row.MonitorID,
"ts": row.Ts.Format(time.RFC3339),
"score": row.Score,
"rtt_valid": row.Rtt.Valid,
"id": row.ID,
"monitor_id": row.MonitorID,
"ts": row.Ts.Format(time.RFC3339),
"score": row.Score,
"rtt_valid": row.Rtt.Valid,
"offset_valid": row.Offset.Valid,
})
}

View File

@@ -30,7 +30,7 @@ func NewCLI() *CLI {
// RootCmd represents the base command when called without any subcommands
func (cli *CLI) rootCmd() *cobra.Command {
var cmd = &cobra.Command{
cmd := &cobra.Command{
Use: "data-api",
Short: "A brief description of your application",
// Uncomment the following line if your bare application
@@ -47,7 +47,6 @@ func (cli *CLI) rootCmd() *cobra.Command {
// Execute adds all child commands to the root command and sets flags appropriately.
// This is called by main.main(). It only needs to happen once to the rootCmd.
func Execute() {
cli := NewCLI()
if err := cli.root.Execute(); err != nil {
@@ -57,7 +56,6 @@ func Execute() {
}
func (cli *CLI) init(cmd *cobra.Command) {
logger.Setup()
cmd.PersistentFlags().StringVar(&cfgFile, "database-config", "database.yaml", "config file (default is $HOME/.data-api.yaml)")

View File

@@ -18,8 +18,7 @@ import (
)
func (cli *CLI) serverCmd() *cobra.Command {
var serverCmd = &cobra.Command{
serverCmd := &cobra.Command{
Use: "server",
Short: "server starts the API server",
Long: `starts the API server on (default) port 8000`,

View File

@@ -33,7 +33,6 @@ func GetHistoryClickHouse(ctx context.Context, ch *chdb.ClickHouse, db *sql.DB,
log.DebugContext(ctx, "GetHistoryCH", "server", serverID, "monitor", monitorID, "since", since, "count", count, "full_history", fullHistory)
ls, err := ch.Logscores(ctx, int(serverID), int(monitorID), since, count, fullHistory)
if err != nil {
log.ErrorContext(ctx, "clickhouse logscores", "err", err)
return nil, err

View File

@@ -21,7 +21,6 @@ func (d Driver) Driver() driver.Driver {
func (d Driver) Connect(ctx context.Context) (driver.Conn, error) {
connector, err := d.CreateConnectorFunc()
if err != nil {
return nil, fmt.Errorf("error creating connector from function: %w", err)
}

View File

@@ -145,7 +145,6 @@ func (ns NullMonitorsType) Value() (driver.Value, error) {
type ServerScoresStatus string
const (
ServerScoresStatusNew ServerScoresStatus = "new"
ServerScoresStatusCandidate ServerScoresStatus = "candidate"
ServerScoresStatusTesting ServerScoresStatus = "testing"
ServerScoresStatusActive ServerScoresStatus = "active"

View File

@@ -16,8 +16,10 @@ import (
"go.ntppool.org/data-api/ntpdb"
)
const pointBasis float64 = 10000
const pointSymbol = "‱"
const (
pointBasis float64 = 10000
pointSymbol = "‱"
)
// const pointBasis = 1000
// const pointSymbol = "‰"
@@ -163,5 +165,4 @@ func (srv *Server) dnsAnswers(c echo.Context) error {
c.Response().Header().Set("Cache-Control", "public,max-age=1800")
return c.JSONPretty(http.StatusOK, r, "")
}

View File

@@ -84,7 +84,6 @@ func (srv *Server) zoneCounts(c echo.Context) error {
} else {
// skip everything and use the special logic that we always include the most recent date
skipCount = float64(count) + 1
}
}
@@ -144,5 +143,4 @@ func (srv *Server) zoneCounts(c echo.Context) error {
c.Response().Header().Set("Cache-Control", "s-maxage=28800, max-age=7200")
return c.JSON(http.StatusOK, rv)
}