Skip to content

Commit 6f270f3

Browse files
authored
Create golangci-lint.yml (#313)
1 parent b4fe018 commit 6f270f3

File tree

8 files changed

+75
-55
lines changed

8 files changed

+75
-55
lines changed

.github/workflows/golangci-lint.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: golangci-lint
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
golangci:
13+
name: lint
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v3
17+
- uses: actions/setup-go@v4
18+
with:
19+
go-version: '1.21'
20+
cache: false
21+
- name: golangci-lint
22+
uses: golangci/golangci-lint-action@v3
23+
with:
24+
version: v1.55
25+
working-directory: v2

v2/goi18n/main.go

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,38 @@
11
// Command goi18n manages message files used by the i18n package.
22
//
3-
// go get -u github.com/nicksnyder/go-i18n/v2/goi18n
4-
// goi18n -help
3+
// go get -u github.com/nicksnyder/go-i18n/v2/goi18n
4+
// goi18n -help
55
//
66
// Use `goi18n extract` to create a message file that contains the messages defined in your Go source files.
7-
// # en.toml
8-
// [PersonCats]
9-
// description = "The number of cats a person has"
10-
// one = "{{.Name}} has {{.Count}} cat."
11-
// other = "{{.Name}} has {{.Count}} cats."
7+
//
8+
// # en.toml
9+
// [PersonCats]
10+
// description = "The number of cats a person has"
11+
// one = "{{.Name}} has {{.Count}} cat."
12+
// other = "{{.Name}} has {{.Count}} cats."
1213
//
1314
// Use `goi18n merge` to create message files for translation.
14-
// # translate.es.toml
15-
// [PersonCats]
16-
// description = "The number of cats a person has"
17-
// hash = "sha1-f937a0e05e19bfe6cd70937c980eaf1f9832f091"
18-
// one = "{{.Name}} has {{.Count}} cat."
19-
// other = "{{.Name}} has {{.Count}} cats."
15+
//
16+
// # translate.es.toml
17+
// [PersonCats]
18+
// description = "The number of cats a person has"
19+
// hash = "sha1-f937a0e05e19bfe6cd70937c980eaf1f9832f091"
20+
// one = "{{.Name}} has {{.Count}} cat."
21+
// other = "{{.Name}} has {{.Count}} cats."
2022
//
2123
// Use `goi18n merge` to merge translated message files with your existing message files.
22-
// # active.es.toml
23-
// [PersonCats]
24-
// description = "The number of cats a person has"
25-
// hash = "sha1-f937a0e05e19bfe6cd70937c980eaf1f9832f091"
26-
// one = "{{.Name}} tiene {{.Count}} gato."
27-
// other = "{{.Name}} tiene {{.Count}} gatos."
24+
//
25+
// # active.es.toml
26+
// [PersonCats]
27+
// description = "The number of cats a person has"
28+
// hash = "sha1-f937a0e05e19bfe6cd70937c980eaf1f9832f091"
29+
// one = "{{.Name}} tiene {{.Count}} gato."
30+
// other = "{{.Name}} tiene {{.Count}} gatos."
2831
//
2932
// Load the active messages into your bundle.
30-
// bundle.RegisterUnmarshalFunc("toml", toml.Unmarshal)
31-
// bundle.MustLoadMessageFile("active.es.toml")
33+
//
34+
// bundle.RegisterUnmarshalFunc("toml", toml.Unmarshal)
35+
// bundle.MustLoadMessageFile("active.es.toml")
3236
package main
3337

3438
import (

v2/i18n/bundlefs.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// +build go1.16
2-
31
package i18n
42

53
import (

v2/i18n/doc.go

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,27 @@
22
// according to a set of locale preferences.
33
//
44
// Create a Bundle to use for the lifetime of your application.
5-
// bundle := i18n.NewBundle(language.English)
5+
//
6+
// bundle := i18n.NewBundle(language.English)
67
//
78
// Load translations into your bundle during initialization.
8-
// bundle.LoadMessageFile("en-US.yaml")
9+
//
10+
// bundle.LoadMessageFile("en-US.yaml")
911
//
1012
// Create a Localizer to use for a set of language preferences.
11-
// func(w http.ResponseWriter, r *http.Request) {
12-
// lang := r.FormValue("lang")
13-
// accept := r.Header.Get("Accept-Language")
14-
// localizer := i18n.NewLocalizer(bundle, lang, accept)
15-
// }
13+
//
14+
// func(w http.ResponseWriter, r *http.Request) {
15+
// lang := r.FormValue("lang")
16+
// accept := r.Header.Get("Accept-Language")
17+
// localizer := i18n.NewLocalizer(bundle, lang, accept)
18+
// }
1619
//
1720
// Use the Localizer to lookup messages.
18-
// localizer.MustLocalize(&i18n.LocalizeConfig{
19-
// DefaultMessage: &i18n.Message{
20-
// ID: "HelloWorld",
21-
// Other: "Hello World!",
22-
// },
23-
// })
21+
//
22+
// localizer.MustLocalize(&i18n.LocalizeConfig{
23+
// DefaultMessage: &i18n.Message{
24+
// ID: "HelloWorld",
25+
// Other: "Hello World!",
26+
// },
27+
// })
2428
package i18n

v2/i18n/localizer.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,6 @@ func (e *MessageNotFoundErr) Error() string {
9090
return fmt.Sprintf("message %q not found in language %q", e.MessageID, e.Tag)
9191
}
9292

93-
type pluralizeErr struct {
94-
messageID string
95-
tag language.Tag
96-
}
97-
98-
func (e *pluralizeErr) Error() string {
99-
return fmt.Sprintf("unable to pluralize %q because there no plural rule for %q", e.messageID, e.tag)
100-
}
101-
10293
type messageIDMismatchErr struct {
10394
messageID string
10495
defaultMessageID string

v2/internal/plural/codegen/main.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,6 @@ func infof(format string, args ...interface{}) {
127127

128128
var verbose bool
129129

130-
func verbosef(format string, args ...interface{}) {
131-
if verbose {
132-
infof(format, args...)
133-
}
134-
}
135-
136130
func fatalf(format string, args ...interface{}) {
137131
infof("fatal: "+format+"\n", args...)
138132
os.Exit(1)

v2/internal/plural/codegen/xml.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ import (
66
"regexp"
77
"strconv"
88
"strings"
9+
10+
"golang.org/x/text/cases"
11+
"golang.org/x/text/language"
912
)
1013

1114
// SupplementalData is the top level struct of plural.xml
@@ -22,7 +25,7 @@ type PluralGroup struct {
2225

2326
// Name returns a unique name for this plural group.
2427
func (pg *PluralGroup) Name() string {
25-
n := strings.Title(pg.Locales)
28+
n := cases.Title(language.AmericanEnglish).String(pg.Locales)
2629
return strings.Replace(n, " ", "", -1)
2730
}
2831

@@ -39,7 +42,7 @@ type PluralRule struct {
3942

4043
// CountTitle returns the title case of the PluralRule's count.
4144
func (pr *PluralRule) CountTitle() string {
42-
return strings.Title(pr.Count)
45+
return cases.Title(language.AmericanEnglish).String(pr.Count)
4346
}
4447

4548
// Condition returns the condition where the PluralRule applies.
@@ -100,7 +103,8 @@ func (pr *PluralRule) GoCondition() string {
100103
if parts == nil {
101104
continue
102105
}
103-
lvar, lmod, op, rhs := strings.Title(parts[1]), parts[2], parts[3], strings.TrimSpace(parts[4])
106+
lvar := cases.Title(language.AmericanEnglish).String(parts[1])
107+
lmod, op, rhs := parts[2], parts[3], strings.TrimSpace(parts[4])
104108
if op == "=" {
105109
op = "=="
106110
}

v2/internal/plural/rule_gen_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ func TestPt(t *testing.T) {
375375
}
376376
}
377377

378-
func TestCaItPt_PTVec(t *testing.T) {
378+
func TestCaItPt_ptVec(t *testing.T) {
379379
var tests []pluralFormTest
380380

381381
tests = appendIntegerTests(tests, One, []string{"1"})

0 commit comments

Comments
 (0)