mirror of
https://github.com/safing/portmaster
synced 2025-09-04 03:29:12 +00:00
Fix linter errors
This commit is contained in:
parent
b552e3f7a5
commit
fd83534698
9 changed files with 13 additions and 18 deletions
|
@ -5,7 +5,7 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
@ -72,7 +72,7 @@ func broadcastNotify(ctx context.Context, t *modules.Task) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to get broadcast notifications update: %w", err)
|
return fmt.Errorf("failed to get broadcast notifications update: %w", err)
|
||||||
}
|
}
|
||||||
broadcastsData, err := ioutil.ReadFile(broadcastsResource.Path())
|
broadcastsData, err := os.ReadFile(broadcastsResource.Path())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to load broadcast notifications update: %w", err)
|
return fmt.Errorf("failed to load broadcast notifications update: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@ package main
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
@ -17,7 +16,7 @@ func checkAndCreateInstanceLock(path, name string) (pid int32, err error) {
|
||||||
lockFilePath := filepath.Join(dataRoot.Path, path, fmt.Sprintf("%s-lock.pid", name))
|
lockFilePath := filepath.Join(dataRoot.Path, path, fmt.Sprintf("%s-lock.pid", name))
|
||||||
|
|
||||||
// read current pid file
|
// read current pid file
|
||||||
data, err := ioutil.ReadFile(lockFilePath)
|
data, err := os.ReadFile(lockFilePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
// create new lock
|
// create new lock
|
||||||
|
@ -78,7 +77,7 @@ func createInstanceLock(lockFilePath string) error {
|
||||||
|
|
||||||
// create lock file
|
// create lock file
|
||||||
// TODO: Investigate required permissions.
|
// TODO: Investigate required permissions.
|
||||||
err = ioutil.WriteFile(lockFilePath, []byte(fmt.Sprintf("%d", os.Getpid())), 0o0666) //nolint:gosec
|
err = os.WriteFile(lockFilePath, []byte(fmt.Sprintf("%d", os.Getpid())), 0o0666) //nolint:gosec
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"time"
|
"time"
|
||||||
|
@ -124,7 +123,7 @@ func writeAsJSON(path string, data any) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write to disk.
|
// Write to disk.
|
||||||
err = ioutil.WriteFile(path, jsonData, 0o0644) //nolint:gosec
|
err = os.WriteFile(path, jsonData, 0o0644) //nolint:gosec
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@ import (
|
||||||
"encoding/xml"
|
"encoding/xml"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sort"
|
"sort"
|
||||||
|
@ -42,7 +41,7 @@ func GetWFPState() (*SimplifiedWFPState, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get tmp file contents.
|
// Get tmp file contents.
|
||||||
output, err := ioutil.ReadFile(tmpFile)
|
output, err := os.ReadFile(tmpFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to read wfp state to tmp file: %w", err)
|
return nil, fmt.Errorf("failed to read wfp state to tmp file: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ package filterlists
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
@ -212,7 +212,7 @@ func updateListIndex() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update list index from updates.
|
// Update list index from updates.
|
||||||
blob, err := ioutil.ReadFile(listIndexUpdate.Path())
|
blob, err := os.ReadFile(listIndexUpdate.Path())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
@ -76,7 +75,7 @@ func (ch *ChartHandler) parseRequest(req *http.Request) (*QueryActiveConnectionC
|
||||||
}
|
}
|
||||||
|
|
||||||
var requestPayload QueryActiveConnectionChartPayload
|
var requestPayload QueryActiveConnectionChartPayload
|
||||||
blob, err := ioutil.ReadAll(body)
|
blob, err := io.ReadAll(body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to read body" + err.Error())
|
return nil, fmt.Errorf("failed to read body" + err.Error())
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -120,7 +119,7 @@ func (qh *QueryHandler) parseRequest(req *http.Request) (*QueryRequestPayload, e
|
||||||
}
|
}
|
||||||
|
|
||||||
var requestPayload QueryRequestPayload
|
var requestPayload QueryRequestPayload
|
||||||
blob, err := ioutil.ReadAll(body)
|
blob, err := io.ReadAll(body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to read body" + err.Error())
|
return nil, fmt.Errorf("failed to read body" + err.Error())
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,7 +116,7 @@ func findSocketFromPid(pid int, socketName string) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// readDirNames only reads the directory names. Using ioutil.ReadDir() would call `lstat` on every
|
// readDirNames only reads the directory names. Using os.ReadDir() would call `lstat` on every
|
||||||
// resulting directory name, which we don't need. This function will be called a lot, so we should
|
// resulting directory name, which we don't need. This function will be called a lot, so we should
|
||||||
// refrain from unnecessary work.
|
// refrain from unnecessary work.
|
||||||
func readDirNames(dir string) (names []string) {
|
func readDirNames(dir string) (names []string) {
|
||||||
|
|
|
@ -5,7 +5,7 @@ import (
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"time"
|
"time"
|
||||||
|
@ -95,7 +95,7 @@ func (hr *HTTPSResolver) Query(ctx context.Context, q *Query) (*RRCache, error)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// Try to read the result
|
// Try to read the result
|
||||||
body, err := ioutil.ReadAll(resp.Body)
|
body, err := io.ReadAll(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue