Skip to content

Commit

Permalink
chore: run go generate ./... (ooni#1343)
Browse files Browse the repository at this point in the history
The https://github.com/iancoleman/strcase library changed its default
behavior between v0.2.0 and v0.3.0 such that:

- before `DNS_NXDOMAIN_error` became `DNSNXDOMAINError`;

- now it becomes `DnsNxdomainError`.

In the grand scheme of things, perhaps, this change makes sense for the
library. However, as a user, what I see is a breaking change between two
minor versions (admittedly we're at v0.x).

Because I don't know what would happen next and I don't want any more
surprises, I am forking [email protected].

This work is part of ooni/probe#2524
  • Loading branch information
bassosimone authored and Murphy-OrangeMud committed Feb 13, 2024
1 parent a674c6a commit 1fb2502
Show file tree
Hide file tree
Showing 22 changed files with 818 additions and 71 deletions.
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ require (
github.com/google/uuid v1.3.1
github.com/gorilla/websocket v1.5.0
github.com/hexops/gotextdiff v1.0.3
github.com/iancoleman/strcase v0.3.0
github.com/mattn/go-colorable v0.1.13
github.com/miekg/dns v1.1.56
github.com/mitchellh/go-wordwrap v1.0.1
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,6 @@ github.com/hinshun/vt10x v0.0.0-20220119200601-820417d04eec h1:qv2VnGeEQHchGaZ/u
github.com/hinshun/vt10x v0.0.0-20220119200601-820417d04eec/go.mod h1:Q48J4R4DvxnHolD5P8pOtXigYlRuPLGl6moFx3ulM68=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg=
github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI=
github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
Expand Down
192 changes: 140 additions & 52 deletions internal/netxlite/certifi.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/netxlite/errno.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/netxlite/errno_darwin.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/netxlite/errno_darwin_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/netxlite/errno_freebsd.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/netxlite/errno_freebsd_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/netxlite/errno_linux.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/netxlite/errno_linux_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/netxlite/errno_openbsd.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/netxlite/errno_openbsd_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/netxlite/errno_windows.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/netxlite/errno_windows_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions internal/netxlite/internal/generrno/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"sort"
"time"

"github.com/iancoleman/strcase"
"github.com/ooni/probe-cli/v3/internal/strcasex"
"golang.org/x/sys/execabs"
)

Expand Down Expand Up @@ -69,12 +69,12 @@ func (es *ErrorSpec) AsCanonicalErrnoName() string {

// AsFailureVar returns the name of the failure var.
func (es *ErrorSpec) AsFailureVar() string {
return "Failure" + strcase.ToCamel(es.failure)
return "Failure" + strcasex.ToCamel(es.failure)
}

// AsFailureString returns the OONI failure string.
func (es *ErrorSpec) AsFailureString() string {
return strcase.ToSnake(es.failure)
return strcasex.ToSnake(es.failure)
}

// NewSystemError constructs a new ErrorSpec representing a system
Expand Down
4 changes: 2 additions & 2 deletions internal/registry/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
"reflect"
"strconv"

"github.com/iancoleman/strcase"
"github.com/ooni/probe-cli/v3/internal/model"
"github.com/ooni/probe-cli/v3/internal/strcasex"
)

// Factory allows to construct an experiment measurer.
Expand Down Expand Up @@ -201,7 +201,7 @@ func (b *Factory) NewExperimentMeasurer() model.ExperimentMeasurer {
// compatibility with MK, we need to add some exceptions here when
// mapping (e.g., DNSCheck => dnscheck).
func CanonicalizeExperimentName(name string) string {
switch name = strcase.ToSnake(name); name {
switch name = strcasex.ToSnake(name); name {
case "ndt_7":
name = "ndt" // since 2020-03-18, we use ndt7 to implement ndt by default
case "dns_check":
Expand Down
12 changes: 12 additions & 0 deletions internal/strcasex/acronyms.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// SPDX-License-Identifier: MIT

package strcasex

var uppercaseAcronym = map[string]string{
"ID": "id",
}

// ConfigureAcronym allows you to add additional words which will be considered acronyms
func ConfigureAcronym(key, val string) {
uppercaseAcronym[key] = val
}
Loading

0 comments on commit 1fb2502

Please sign in to comment.