Skip to content

Commit

Permalink
[chore] lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
leaanthony committed Nov 12, 2023
1 parent d88a741 commit 9ce0ddb
Show file tree
Hide file tree
Showing 107 changed files with 312 additions and 355 deletions.
2 changes: 0 additions & 2 deletions v2/cmd/wails/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
)

func buildApplication(f *flags.Build) error {

if f.NoColour {
pterm.DisableColor()
colour.ColourEnabled = false
Expand Down Expand Up @@ -255,5 +254,4 @@ func buildApplication(f *flags.Build) error {
}

return nil

}
5 changes: 2 additions & 3 deletions v2/cmd/wails/dev.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package main

import (
"os"

"github.com/pterm/pterm"
"github.com/wailsapp/wails/v2/cmd/wails/flags"
"github.com/wailsapp/wails/v2/cmd/wails/internal/dev"
"github.com/wailsapp/wails/v2/internal/colour"
"github.com/wailsapp/wails/v2/pkg/clilogger"
"os"
)

func devApplication(f *flags.Dev) error {

if f.NoColour {
pterm.DisableColor()
colour.ColourEnabled = false
Expand All @@ -34,5 +34,4 @@ func devApplication(f *flags.Dev) error {
}

return dev.Application(f, logger)

}
4 changes: 2 additions & 2 deletions v2/cmd/wails/doctor.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ func diagnoseEnvironment(f *flags.Doctor) error {
// Output Dependencies Status
var dependenciesMissing []string
var externalPackages []*packagemanager.Dependency
var dependenciesAvailableRequired = 0
var dependenciesAvailableOptional = 0
dependenciesAvailableRequired := 0
dependenciesAvailableOptional := 0

dependenciesTableData := pterm.TableData{
{"Dependency", "Package Name", "Status", "Version"},
Expand Down
2 changes: 0 additions & 2 deletions v2/cmd/wails/flags/dev.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ func (*Dev) Default() *Dev {
}

func (d *Dev) Process() error {

var err error
err = d.loadAndMergeProjectConfig()
if err != nil {
Expand Down Expand Up @@ -113,7 +112,6 @@ func (d *Dev) loadAndMergeProjectConfig() error {
}

return nil

}

// GenerateBuildOptions creates a build.Options using the flags
Expand Down
1 change: 0 additions & 1 deletion v2/cmd/wails/flags/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ type Init struct {
}

func (i *Init) Default() *Init {

result := &Init{
TemplateName: "vanilla",
}
Expand Down
13 changes: 6 additions & 7 deletions v2/cmd/wails/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ package main

import (
"fmt"
"os"
"path/filepath"

"github.com/leaanthony/debme"
"github.com/leaanthony/gosod"
"github.com/pterm/pterm"
Expand All @@ -14,12 +17,9 @@ import (
"github.com/wailsapp/wails/v2/pkg/clilogger"
"github.com/wailsapp/wails/v2/pkg/commands/bindings"
"github.com/wailsapp/wails/v2/pkg/commands/buildtags"
"os"
"path/filepath"
)

func generateModule(f *flags.GenerateModule) error {

if f.NoColour {
pterm.DisableColor()
colour.ColourEnabled = false
Expand Down Expand Up @@ -55,7 +55,6 @@ func generateModule(f *flags.GenerateModule) error {
}

func generateTemplate(f *flags.GenerateTemplate) error {

if f.NoColour {
pterm.DisableColor()
colour.ColourEnabled = false
Expand All @@ -77,7 +76,7 @@ func generateTemplate(f *flags.GenerateTemplate) error {
}
templateDir := filepath.Join(cwd, f.Name)
if !fs.DirExists(templateDir) {
err := os.MkdirAll(templateDir, 0755)
err := os.MkdirAll(templateDir, 0o755)
if err != nil {
return err
}
Expand Down Expand Up @@ -200,7 +199,7 @@ func processPackageJSON(frontendDir string) error {
json, _ = sjson.SetBytes(json, "name", "{{.ProjectName}}")
json, _ = sjson.SetBytes(json, "author", "{{.AuthorName}}")

err = os.WriteFile(packageJSON, json, 0644)
err = os.WriteFile(packageJSON, json, 0o644)
if err != nil {
return err
}
Expand Down Expand Up @@ -231,7 +230,7 @@ func processPackageLockJSON(frontendDir string) error {
printBulletPoint("Updating package-lock.json data...")
json, _ = sjson.Set(json, "name", "{{.ProjectName}}")

err = os.WriteFile(filename, []byte(json), 0644)
err = os.WriteFile(filename, []byte(json), 0o644)
if err != nil {
return err
}
Expand Down
16 changes: 8 additions & 8 deletions v2/cmd/wails/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ package main
import (
"bufio"
"fmt"
"os"
"os/exec"
"path/filepath"
"strings"
"time"

"github.com/flytam/filenamify"
"github.com/leaanthony/slicer"
"github.com/pkg/errors"
Expand All @@ -13,15 +19,9 @@ import (
"github.com/wailsapp/wails/v2/pkg/clilogger"
"github.com/wailsapp/wails/v2/pkg/git"
"github.com/wailsapp/wails/v2/pkg/templates"
"os"
"os/exec"
"path/filepath"
"strings"
"time"
)

func initProject(f *flags.Init) error {

if f.NoColour {
pterm.DisableColor()
colour.ColourEnabled = false
Expand Down Expand Up @@ -215,7 +215,7 @@ func initGit(options *templates.Options) error {
"frontend/dist",
"frontend/node_modules",
}
err = os.WriteFile(filepath.Join(options.TargetDir, ".gitignore"), []byte(strings.Join(ignore, "\n")), 0644)
err = os.WriteFile(filepath.Join(options.TargetDir, ".gitignore"), []byte(strings.Join(ignore, "\n")), 0o644)
if err != nil {
return errors.Wrap(err, "Unable to create gitignore")
}
Expand Down Expand Up @@ -271,7 +271,7 @@ func updateReplaceLine(targetPath string) {
}
}

err = os.WriteFile("go.mod", []byte(strings.Join(lines, "\n")), 0644)
err = os.WriteFile("go.mod", []byte(strings.Join(lines, "\n")), 0o644)
if err != nil {
fatal(err.Error())
}
Expand Down
5 changes: 1 addition & 4 deletions v2/cmd/wails/internal/dev/dev.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ func sliceToMap(input []string) map[string]struct{} {

// Application runs the application in dev mode
func Application(f *flags.Dev, logger *clilogger.CLILogger) error {

cwd := lo.Must(os.Getwd())

// Update go.mod to use current wails version
Expand Down Expand Up @@ -271,7 +270,6 @@ func runFrontendDevWatcherCommand(frontendDirectory string, devCommand string, d

// restartApp does the actual rebuilding of the application when files change
func restartApp(buildOptions *build.Options, debugBinaryProcess *process.Process, f *flags.Dev, exitCodeChannel chan int, legacyUseDevServerInsteadofCustomScheme bool) (*process.Process, string, error) {

appBinary, err := build.Build(buildOptions)
println()
if err != nil {
Expand All @@ -298,7 +296,6 @@ func restartApp(buildOptions *build.Options, debugBinaryProcess *process.Process

// parse appargs if any
args, err := shlex.Split(f.AppArgs)

if err != nil {
buildOptions.Logger.Fatal("Unable to parse appargs: %s", err.Error())
}
Expand Down Expand Up @@ -345,7 +342,7 @@ func doWatcherLoop(cwd string, buildOptions *build.Options, debugBinaryProcess *
logutils.LogGreen("Watching (sub)/directory: %s", cwd)

// Main Loop
var extensionsThatTriggerARebuild = sliceToMap(strings.Split(f.Extensions, ","))
extensionsThatTriggerARebuild := sliceToMap(strings.Split(f.Extensions, ","))
var dirsThatTriggerAReload []string
for _, dir := range strings.Split(f.ReloadDirs, ",") {
if dir == "" {
Expand Down
1 change: 0 additions & 1 deletion v2/cmd/wails/internal/dev/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ type Watcher interface {

// initialiseWatcher creates the project directory watcher that will trigger recompile
func initialiseWatcher(cwd string) (*fsnotify.Watcher, error) {

// Ignore dot files, node_modules and build directories by default
ignoreDirs := getIgnoreDirs(cwd)

Expand Down
2 changes: 1 addition & 1 deletion v2/cmd/wails/internal/gomod/gomod.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func SyncGoMod(logger *clilogger.CLILogger, updateWailsVersion bool) error {
}

if updated {
return os.WriteFile(gomodFilename, gomodData, 0755)
return os.WriteFile(gomodFilename, gomodData, 0o755)
}

return nil
Expand Down
1 change: 0 additions & 1 deletion v2/cmd/wails/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ func bool2Str(b bool) string {
var app *clir.Cli

func main() {

var err error

app = clir.NewCli("Wails", "Go/HTML Appkit", internal.Version)
Expand Down
4 changes: 1 addition & 3 deletions v2/cmd/wails/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (

// AddSubcommand adds the `init` command for the Wails application
func update(f *flags.Update) error {

if f.NoColour {
colour.ColourEnabled = false
pterm.DisableColor()
Expand Down Expand Up @@ -73,8 +72,7 @@ func update(f *flags.Update) error {
}

func updateToVersion(targetVersion *github.SemanticVersion, force bool, currentVersion string) error {

var targetVersionString = "v" + targetVersion.String()
targetVersionString := "v" + targetVersion.String()

if targetVersionString == currentVersion {
pterm.Println("\nLooks like you're up to date!")
Expand Down
6 changes: 4 additions & 2 deletions v2/examples/customlayout/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module changeme

go 1.18
go 1.21

toolchain go1.21.0

require github.com/wailsapp/wails/v2 v2.1.0

Expand All @@ -24,7 +26,7 @@ require (
github.com/tkrajina/go-reflector v0.5.6 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasttemplate v1.2.2 // indirect
github.com/wailsapp/go-webview2 v1.0.7 // indirect
github.com/wailsapp/go-webview2 v1.0.10 // indirect
github.com/wailsapp/mimetype v1.4.1 // indirect
golang.org/x/crypto v0.14.0 // indirect
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 // indirect
Expand Down
1 change: 1 addition & 0 deletions v2/examples/customlayout/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQ
github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
github.com/wailsapp/go-webview2 v1.0.7 h1:s95+7irJsAsTy1RsjJ6N0cYX7tZ4gP7Uzawds0L2urs=
github.com/wailsapp/go-webview2 v1.0.7/go.mod h1:Uk2BePfCRzttBBjFrBmqKGJd41P6QIHeV9kTgIeOZNo=
github.com/wailsapp/go-webview2 v1.0.10/go.mod h1:Uk2BePfCRzttBBjFrBmqKGJd41P6QIHeV9kTgIeOZNo=
github.com/wailsapp/mimetype v1.4.1 h1:pQN9ycO7uo4vsUUuPeHEYoUkLVkaRntMnHJxVwYhwHs=
github.com/wailsapp/mimetype v1.4.1/go.mod h1:9aV5k31bBOv5z6u+QP8TltzvNGJPmNJD4XlAL3U+j3o=
golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc=
Expand Down
4 changes: 3 additions & 1 deletion v2/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module github.com/wailsapp/wails/v2

go 1.18
go 1.21

toolchain go1.21.0

require (
github.com/Masterminds/semver v1.5.0
Expand Down
17 changes: 9 additions & 8 deletions v2/internal/app/app_devtools_not.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
//go:build !devtools

package app

// Note: devtools flag is also added in debug builds
func IsDevtoolsEnabled() bool {
return false
}
//go:build !devtools

package app

// IsDevtoolsEnabled returns true if devtools should be enabled
// Note: devtools flag is also added in debug builds
func IsDevtoolsEnabled() bool {
return false
}
4 changes: 1 addition & 3 deletions v2/internal/binding/binding.go
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ func NewBindings(logger *logger.Logger, structPointersToBind []interface{}, exem

// Add the given struct methods to the Bindings
func (b *Bindings) Add(structPtr interface{}) error {

methods, err := b.getMethods(structPtr)
if err != nil {
return fmt.Errorf("cannot bind value to app: %s", err.Error())
Expand Down Expand Up @@ -146,7 +145,6 @@ func (b *Bindings) GenerateModels() ([]byte, error) {
}

func (b *Bindings) WriteModels(modelsDir string) error {

modelsData, err := b.GenerateModels()
if err != nil {
return err
Expand All @@ -157,7 +155,7 @@ func (b *Bindings) WriteModels(modelsDir string) error {
}

filename := filepath.Join(modelsDir, "models.ts")
err = os.WriteFile(filename, modelsData, 0755)
err = os.WriteFile(filename, modelsData, 0o755)
if err != nil {
return err
}
Expand Down
1 change: 0 additions & 1 deletion v2/internal/binding/boundMethod.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ func (b *BoundMethod) OutputCount() int {

// ParseArgs method converts the input json into the types expected by the method
func (b *BoundMethod) ParseArgs(args []json.RawMessage) ([]interface{}, error) {

result := make([]interface{}, b.InputCount())
if len(args) != b.InputCount() {
return nil, fmt.Errorf("received %d arguments to method '%s', expected %d", len(args), b.Name, b.InputCount())
Expand Down
8 changes: 1 addition & 7 deletions v2/internal/binding/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ func newDB() *DB {
// GetMethodFromStore returns the method for the given package/struct/method names
// nil is returned if any one of those does not exist
func (d *DB) GetMethodFromStore(packageName string, structName string, methodName string) *BoundMethod {

// Lock the db whilst processing and unlock on return
d.lock.RLock()
defer d.lock.RUnlock()
Expand All @@ -53,7 +52,6 @@ func (d *DB) GetMethodFromStore(packageName string, structName string, methodNam
// GetMethod returns the method for the given qualified method name
// qualifiedMethodName is "packagename.structname.methodname"
func (d *DB) GetMethod(qualifiedMethodName string) *BoundMethod {

// Lock the db whilst processing and unlock on return
d.lock.RLock()
defer d.lock.RUnlock()
Expand All @@ -72,7 +70,6 @@ func (d *DB) GetObfuscatedMethod(id int) *BoundMethod {

// AddMethod adds the given method definition to the db using the given qualified path: packageName.structName.methodName
func (d *DB) AddMethod(packageName string, structName string, methodName string, methodDefinition *BoundMethod) {

// Lock the db whilst processing and unlock on return
d.lock.Lock()
defer d.lock.Unlock()
Expand All @@ -99,12 +96,10 @@ func (d *DB) AddMethod(packageName string, structName string, methodName string,
// Store in the methodMap
key := packageName + "." + structName + "." + methodName
d.methodMap[key] = methodDefinition

}

// ToJSON converts the method map to JSON
func (d *DB) ToJSON() (string, error) {

// Lock the db whilst processing and unlock on return
d.lock.RLock()
defer d.lock.RUnlock()
Expand All @@ -120,8 +115,7 @@ func (d *DB) ToJSON() (string, error) {

// UpdateObfuscatedCallMap sets up the secure call mappings
func (d *DB) UpdateObfuscatedCallMap() map[string]int {

var mappings = make(map[string]int)
mappings := make(map[string]int)

// Iterate map keys and sort them
keys := make([]string, 0, len(d.methodMap))
Expand Down
Loading

0 comments on commit 9ce0ddb

Please sign in to comment.