mirror of
https://bitbucket.org/s_l_teichmann/mtsatellite
synced 2024-11-15 14:50:21 +01:00
Fix issues found by staticcheck
This commit is contained in:
parent
65762936a4
commit
5442fab97d
|
@ -13,6 +13,7 @@ import (
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"bitbucket.org/s_l_teichmann/mtsatellite/common"
|
"bitbucket.org/s_l_teichmann/mtsatellite/common"
|
||||||
|
@ -135,7 +136,7 @@ func main() {
|
||||||
connChan := make(chan net.Conn)
|
connChan := make(chan net.Conn)
|
||||||
defer close(connChan)
|
defer close(connChan)
|
||||||
sigChan := make(chan os.Signal, 1)
|
sigChan := make(chan os.Signal, 1)
|
||||||
signal.Notify(sigChan, os.Interrupt, os.Kill)
|
signal.Notify(sigChan, os.Interrupt, syscall.SIGTERM)
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
|
|
|
@ -8,7 +8,7 @@ import (
|
||||||
"image"
|
"image"
|
||||||
"image/color"
|
"image/color"
|
||||||
"image/draw"
|
"image/draw"
|
||||||
"io/ioutil"
|
"io/fs"
|
||||||
"log"
|
"log"
|
||||||
"math"
|
"math"
|
||||||
"os"
|
"os"
|
||||||
|
@ -28,10 +28,10 @@ type pyramidCreator struct {
|
||||||
bg color.RGBA
|
bg color.RGBA
|
||||||
}
|
}
|
||||||
|
|
||||||
func findMaxDir(files []os.FileInfo) (min, max int) {
|
func findMaxDir(files []os.DirEntry) (min, max int) {
|
||||||
min, max = math.MaxInt32, math.MinInt32
|
min, max = math.MaxInt32, math.MinInt32
|
||||||
for _, file := range files {
|
for _, file := range files {
|
||||||
if !file.Mode().IsDir() {
|
if !file.IsDir() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if x, err := strconv.Atoi(file.Name()); err == nil {
|
if x, err := strconv.Atoi(file.Name()); err == nil {
|
||||||
|
@ -46,10 +46,10 @@ func findMaxDir(files []os.FileInfo) (min, max int) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func findMaxFile(files []os.FileInfo) (min, max int) {
|
func findMaxFile(files []os.DirEntry) (min, max int) {
|
||||||
min, max = math.MaxInt32, math.MinInt32
|
min, max = math.MaxInt32, math.MinInt32
|
||||||
for _, file := range files {
|
for _, file := range files {
|
||||||
if !file.Mode().IsRegular() {
|
if !file.Type().IsRegular() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
name := file.Name()
|
name := file.Name()
|
||||||
|
@ -86,8 +86,8 @@ func (pc *pyramidCreator) createParentLevel(
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var files []os.FileInfo
|
var files []fs.DirEntry
|
||||||
if files, err = ioutil.ReadDir(oldDir); err != nil {
|
if files, err = os.ReadDir(oldDir); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ func (pc *pyramidCreator) createParentLevel(
|
||||||
ox1Dir := filepath.Join(oldDir, strconv.Itoa(ox))
|
ox1Dir := filepath.Join(oldDir, strconv.Itoa(ox))
|
||||||
ox2Dir := filepath.Join(oldDir, strconv.Itoa(ox+1))
|
ox2Dir := filepath.Join(oldDir, strconv.Itoa(ox+1))
|
||||||
|
|
||||||
if files, err = ioutil.ReadDir(ox1Dir); err != nil {
|
if files, err = os.ReadDir(ox1Dir); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
zMin, zMax := findMaxFile(files)
|
zMin, zMax := findMaxFile(files)
|
||||||
|
|
|
@ -22,8 +22,6 @@ import (
|
||||||
"github.com/bamiaux/rez"
|
"github.com/bamiaux/rez"
|
||||||
"github.com/jackc/pgx/v4"
|
"github.com/jackc/pgx/v4"
|
||||||
|
|
||||||
"bytes"
|
|
||||||
|
|
||||||
"bitbucket.org/s_l_teichmann/mtsatellite/common"
|
"bitbucket.org/s_l_teichmann/mtsatellite/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -126,7 +124,7 @@ func (tu *tileUpdater) checkIP(r *http.Request) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := range tu.ips {
|
for i := range tu.ips {
|
||||||
if bytes.Compare(tu.ips[i], ip) == 0 {
|
if tu.ips[i].Equal(ip) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,8 @@ package common
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"image/color"
|
"image/color"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
)
|
)
|
||||||
|
@ -177,7 +177,7 @@ func (btc *BaseTileCreator) WriteFunc(i, j int, update BaseTileUpdateFunc) func(
|
||||||
if update == nil && btc.renderer.IsEmpty() {
|
if update == nil && btc.renderer.IsEmpty() {
|
||||||
return func() (bool, error) {
|
return func() (bool, error) {
|
||||||
//log.Printf("Writing empty (%d, %d) to file %s\n", x, z, path)
|
//log.Printf("Writing empty (%d, %d) to file %s\n", x, z, path)
|
||||||
return true, ioutil.WriteFile(path, btc.blankImage(), 0666)
|
return true, os.WriteFile(path, btc.blankImage(), 0666)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -131,6 +131,6 @@ func HashImage(img *image.RGBA) []byte {
|
||||||
|
|
||||||
func BackgroundImage(width, height int, bg color.RGBA) *image.RGBA {
|
func BackgroundImage(width, height int, bg color.RGBA) *image.RGBA {
|
||||||
m := image.NewRGBA(image.Rect(0, 0, width, height))
|
m := image.NewRGBA(image.Rect(0, 0, width, height))
|
||||||
draw.Draw(m, m.Bounds(), &image.Uniform{bg}, image.ZP, draw.Src)
|
draw.Draw(m, m.Bounds(), &image.Uniform{bg}, image.Point{}, draw.Src)
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,19 +64,16 @@ func (r *Renderer) GetPos() (int16, int16) {
|
||||||
|
|
||||||
func (r *Renderer) initBuffers() {
|
func (r *Renderer) initBuffers() {
|
||||||
yb := r.yBuffer
|
yb := r.yBuffer
|
||||||
yb = yb[:len(yb)]
|
|
||||||
for i := range yb {
|
for i := range yb {
|
||||||
yb[i] = math.MinInt32
|
yb[i] = math.MinInt32
|
||||||
}
|
}
|
||||||
|
|
||||||
cb := r.cBuffer
|
cb := r.cBuffer
|
||||||
cb = cb[:len(cb)]
|
|
||||||
for i := range cb {
|
for i := range cb {
|
||||||
cb[i] = -1
|
cb[i] = -1
|
||||||
}
|
}
|
||||||
|
|
||||||
ym := r.yMin
|
ym := r.yMin
|
||||||
ym = ym[:len(ym)]
|
|
||||||
for i := range ym {
|
for i := range ym {
|
||||||
ym[i] = math.MinInt32
|
ym[i] = math.MinInt32
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user