Skip to content

Commit

Permalink
Merge pull request #7 from leighmacdonald/v4
Browse files Browse the repository at this point in the history
Move to v4 package.
  • Loading branch information
leighmacdonald committed Mar 12, 2024
2 parents 8e7fdf7 + 8f94ea6 commit 42bc6d4
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 32 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ static:
@staticcheck -go 1.20 ./...

check_deps:
go install github.com/daixiang0/gci@latest
go install mvdan.cc/gofumpt@latest
go install github.com/daixiang0/gci@v0.13.0
go install mvdan.cc/gofumpt@v0.6.0
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.56.2
go install honnef.co/go/tools/cmd/staticcheck@v0.4.7
go install github.com/goreleaser/goreleaser@latest
go install github.com/goreleaser/goreleaser@v1.24.0

dev_db:
docker compose -f docker-compose-dev.yml up --force-recreate -V postgres
Expand Down
2 changes: 1 addition & 1 deletion cmd/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"os"
"strings"

"github.com/leighmacdonald/steamid/v3/extra"
"github.com/leighmacdonald/steamid/v4/extra"
"github.com/spf13/cobra"
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package cmd
import (
"os"

"github.com/leighmacdonald/steamid/v3/steamid"
"github.com/leighmacdonald/steamid/v4/steamid"
"github.com/spf13/cobra"
)

Expand Down
11 changes: 1 addition & 10 deletions extra/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"io"
"strings"

"github.com/leighmacdonald/steamid/v3/steamid"
"github.com/leighmacdonald/steamid/v4/steamid"
)

var (
Expand All @@ -21,23 +21,14 @@ var (
)

// ParseReader attempt to find all types of steam ids in the data stream provided by the

// input reader. It will write the output of what it finds to the output writer applying the

// formatting strings to each value. The formatting string takes the same formatting as the

// standards fmt.SprintF() and expects one %s token.

//

// A formatting example to place each steam id on a newline: "%s\n"

//

// idType specifies what output id format to use when writing: steam, steam3, steam32, steam64 are

// the valid choices.

func ParseReader(input io.Reader, output io.Writer, format string, idType string) error {
switch idType {
case "steam":
Expand Down
14 changes: 3 additions & 11 deletions extra/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,13 @@ import (
"strings"
"time"

"github.com/leighmacdonald/steamid/v3/steamid"
"github.com/leighmacdonald/steamid/v4/steamid"
)

var (
reStatusID = regexp.MustCompile(`"(.+?)"\s+(\[U:\d+:\d+]|STEAM_\d:\d:\d+)`)

reStatusID = regexp.MustCompile(`"(.+?)"\s+(\[U:\d+:\d+]|STEAM_\d:\d:\d+)`)
reStatusPlayerFull = regexp.MustCompile(`^#\s+(\d+)\s+"(.+?)"\s+(\[U:\d:\d+])\s+(.+?)\s+(\d+)\s+(\d+)\s+(.+?)\s(.+?):(.+?)$`)

reStatusPlayer = regexp.MustCompile(`^#\s+(\d+)\s+"(.+?)"\s+(\[U:\d:\d+])\s+(\d+:\d+)\s+(\d+)\s+(\d+)\s+(.+?)$`)
reStatusPlayer = regexp.MustCompile(`^#\s+(\d+)\s+"(.+?)"\s+(\[U:\d:\d+])\s+(\d+:\d+)\s+(\d+)\s+(\d+)\s+(.+?)$`)
)

var (
Expand Down Expand Up @@ -47,7 +45,6 @@ type Status struct {
}

// Player represents all the available data for a player in a `status` output table.

type Player struct {
UserID int
Name string
Expand All @@ -61,9 +58,7 @@ type Player struct {
}

// SIDSFromStatus will parse the output of the console command `status` and return a

// set of SID64s representing all the players.

func SIDSFromStatus(text string) []steamid.SteamID {
var ids []steamid.SteamID

Expand All @@ -81,11 +76,8 @@ func SIDSFromStatus(text string) []steamid.SteamID {
}

// ParseStatus will parse a status command output into a struct

// If full is true, it will also parse the address/port of the player.

// This only works for status commands via RCON/CLI.

func ParseStatus(status string, full bool) (Status, error) {
var s Status

Expand Down
2 changes: 1 addition & 1 deletion extra/status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package extra_test
import (
"testing"

"github.com/leighmacdonald/steamid/v3/extra"
"github.com/leighmacdonald/steamid/v4/extra"
"github.com/stretchr/testify/require"
)

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/leighmacdonald/steamid/v3
module github.com/leighmacdonald/steamid/v4

go 1.22

Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Copyright © 2020 Leigh MacDonald <leigh.macdonald@gmail.com>
*/
package main

import "github.com/leighmacdonald/steamid/v3/cmd"
import "github.com/leighmacdonald/steamid/v4/cmd"

func main() {
cmd.Execute()
Expand Down
2 changes: 0 additions & 2 deletions steamid/steamid.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@ var (
ErrSIDConvertInt64 = errors.New("failed to convert id to int64")
ErrInvalidGID = errors.New("invalid gid")
ErrDecodeSID = errors.New("could not decode steamid value")
ErrDecodeGID = errors.New("could not decode gid value")
ErrUnmarshalStringSID = errors.New("failed to unmarshal string to SteamID")
ErrUnmarshalStringGID = errors.New("failed to unmarshal string to GID64")
ErrRequestCreate = errors.New("failed to create request")
ErrInvalidStatusCode = errors.New("invalid status code")
ErrResponsePerform = errors.New("failed to perform request")
Expand Down
2 changes: 1 addition & 1 deletion steamid/steamid_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"os"
"testing"

"github.com/leighmacdonald/steamid/v3/steamid"
"github.com/leighmacdonald/steamid/v4/steamid"
"github.com/stretchr/testify/require"
)

Expand Down

0 comments on commit 42bc6d4

Please sign in to comment.