Skip to content

Commit

Permalink
linters
Browse files Browse the repository at this point in the history
  • Loading branch information
donseba committed Feb 1, 2024
1 parent fcc020b commit f282add
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 125 deletions.
105 changes: 0 additions & 105 deletions cli/xgotext/fixtures/main.go

This file was deleted.

4 changes: 0 additions & 4 deletions cli/xgotext/fixtures/pkg/pkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,3 @@ type Translate struct {
L gotext.Locale
S SubTranslate
}

func test() {
gotext.Get("inside sub package")
}
20 changes: 9 additions & 11 deletions cli/xgotext/parser/pkg-tree/golang.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package pkg_tree

import (
"fmt"
"github.com/donseba/gotext/cli/xgotext/parser"
"go/ast"
"go/token"
"go/types"
Expand All @@ -10,9 +11,6 @@ import (
"os"
"path/filepath"
"strconv"
"strings"

"github.com/donseba/gotext/cli/xgotext/parser"
)

const gotextPkgPath = "github.com/donseba/gotext"
Expand Down Expand Up @@ -112,13 +110,13 @@ func loadPackage(name string) (*packages.Package, error) {
return pkgs[0], nil
}

func getPkgPath(pkg *packages.Package) string {
if len(pkg.GoFiles) == 0 {
return pkg.PkgPath
}
pkgPath, _ := filepath.Split(pkg.GoFiles[0])
return strings.TrimRight(pkgPath, "/")
}
//func getPkgPath(pkg *packages.Package) string {
// if len(pkg.GoFiles) == 0 {
// return pkg.PkgPath
// }
// pkgPath, _ := filepath.Split(pkg.GoFiles[0])
// return strings.TrimRight(pkgPath, "/")
//}

func filterPkgs(pkg *packages.Package) []*packages.Package {
result := filterPkgsRec(pkg)
Expand Down Expand Up @@ -147,7 +145,7 @@ type GoFile struct {
data *parser.DomainMap

fileSet *token.FileSet
pkgConf *packages.Config
//pkgConf *packages.Config

importedPackages map[string]*packages.Package
}
Expand Down
2 changes: 1 addition & 1 deletion domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ func (do *Domain) MarshalText() ([]byte, error) {

headerKeys := make([]string, 0, len(do.Headers))

for k, _ := range do.Headers {
for k := range do.Headers {
headerKeys = append(headerKeys, k)
}

Expand Down
2 changes: 1 addition & 1 deletion po_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ func pluralExpected(t *testing.T, pluralTests []pluralTest, domain *Domain) {
for _, pt := range pluralTests {
pt := pt
t.Run(fmt.Sprintf("pluralForm(%d)", pt.num), func(t *testing.T) {
n := domain.pluralForm(pt.num)
n := domain.PluralForm(pt.num)
if n != pt.form {
t.Errorf("Expected %d for pluralForm(%d), got %d", pt.form, pt.num, n)
}
Expand Down
2 changes: 1 addition & 1 deletion translation.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func NewTranslationWithRefs(refs []string) *Translation {
}

func (t *Translation) IsStale() bool {
return t.dirty == false
return !t.dirty
}

func (t *Translation) SetRefs(refs []string) {
Expand Down
3 changes: 1 addition & 2 deletions translator.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ package gotext
import (
"errors"
"io/fs"
"io/ioutil"
"os"
)

Expand Down Expand Up @@ -83,5 +82,5 @@ func getFileData(f string, filesystem fs.FS) ([]byte, error) {
return nil, errors.New("cannot parse a directory")
}

return ioutil.ReadFile(f)
return os.ReadFile(f)
}

0 comments on commit f282add

Please sign in to comment.