Skip to content

Commit

Permalink
feat(server): updated module name to adhere to golang standard
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniloMurer committed Nov 19, 2024
1 parent 92a0956 commit 34c66fd
Show file tree
Hide file tree
Showing 17 changed files with 38 additions and 36 deletions.
5 changes: 2 additions & 3 deletions server/cmd/triffgonix/main.go → server/cmd/main.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package main

import (
"server/internal/triffgonix/api"
"server/internal/triffgonix/database"

"github.com/DaniloMurer/triffgonix/server/internal/api"
"github.com/DaniloMurer/triffgonix/server/internal/database"
"github.com/gin-contrib/cors"
"github.com/gin-gonic/gin"
)
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions server/go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module server
module github.com/DaniloMurer/triffgonix/server

go 1.23.0

Expand All @@ -9,6 +9,7 @@ require github.com/gin-contrib/cors v1.7.2
require gorm.io/gorm v1.25.11

require (
github.com/google/uuid v1.6.0
github.com/gorilla/websocket v1.5.3
github.com/stretchr/testify v1.9.0
gorm.io/driver/sqlite v1.5.6
Expand All @@ -26,7 +27,6 @@ require (
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.20.0 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/json-iterator/go v1.1.12 // indirect
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package api

import (
"github.com/DaniloMurer/triffgonix/server/internal/api/dto"
socket2 "github.com/DaniloMurer/triffgonix/server/internal/api/socket"
"github.com/DaniloMurer/triffgonix/server/internal/dart/engine"
"github.com/DaniloMurer/triffgonix/server/internal/dart/engine/x01"
"github.com/DaniloMurer/triffgonix/server/internal/database"
"github.com/DaniloMurer/triffgonix/server/internal/models"
"github.com/DaniloMurer/triffgonix/server/pkg/logging"
"net/http"
"server/internal/triffgonix/api/dto"
"server/internal/triffgonix/api/socket"
"server/internal/triffgonix/dart/engine"
"server/internal/triffgonix/dart/engine/x01"
"server/internal/triffgonix/database"
"server/internal/triffgonix/models"
"server/pkg/logging"
"strconv"

"github.com/gin-gonic/gin"
Expand All @@ -17,7 +17,7 @@ import (

var (
upgrader = websocket.Upgrader{}
hubs = map[string]socket.Hub{}
hubs = map[string]socket2.Hub{}
generalConnections []*websocket.Conn
)

Expand All @@ -36,14 +36,14 @@ func HandleDartWebSocket(c *gin.Context) {
}
gameId := c.Param("gameId")
// get message from socket
var message socket.IncomingMessage
var message socket2.IncomingMessage
err = conn.ReadJSON(&message)
if err != nil {
logger.Error("error while reading from socket connection: %v", err)
return
}
switch *message.Type {
case socket.Handshake:
case socket2.Handshake:
hub, exists := hubs[gameId]
if exists {
hub.RegisterNewClient(conn)
Expand Down Expand Up @@ -120,7 +120,7 @@ func CreateGame(c *gin.Context) {
Players: &players,
Engine: x01.New(newGame.StartingScore),
}
newHub := socket.Hub{Id: savedGame.Id, Clients: map[*socket.Client]bool{}, Game: game}
newHub := socket2.Hub{Id: savedGame.Id, Clients: map[*socket2.Client]bool{}, Game: game}
hubs[strconv.FormatUint(uint64(savedGame.Id), 10)] = newHub
broadcastNewGame(savedGame)
c.JSON(http.StatusCreated, &savedGame)
Expand All @@ -134,7 +134,7 @@ func GetGames(c *gin.Context) {
func broadcastNewGame(newGame *models.Game) {
game := dto.Game{}
game.FromEntity(newGame)
message := socket.OutgoingMessage{Type: socket.NewGame, Content: game}
message := socket2.OutgoingMessage{Type: socket2.NewGame, Content: game}
for _, conn := range generalConnections {
err := conn.WriteJSON(message)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package api

import (
"github.com/DaniloMurer/triffgonix/server/internal/database"
"github.com/DaniloMurer/triffgonix/server/internal/models"
"github.com/google/uuid"
"net/http/httptest"
"server/internal/triffgonix/database"
"server/internal/triffgonix/models"
"testing"

"github.com/gin-gonic/gin"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package dto

import (
"server/internal/triffgonix/domain"
"server/internal/triffgonix/models"
"github.com/DaniloMurer/triffgonix/server/internal/domain"
"github.com/DaniloMurer/triffgonix/server/internal/models"
)

type Players struct {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package socket

import (
"github.com/DaniloMurer/triffgonix/server/internal/dart/engine"
"github.com/DaniloMurer/triffgonix/server/internal/domain"
"github.com/DaniloMurer/triffgonix/server/pkg/logging"
"github.com/gorilla/websocket"
"server/internal/triffgonix/dart/engine"
"server/internal/triffgonix/domain"
"server/pkg/logging"
)

var logger = logging.NewLogger()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package socket

import (
"server/pkg/logging"
"github.com/DaniloMurer/triffgonix/server/pkg/logging"
"testing"
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package engine

import (
"server/internal/triffgonix/api/dto"
"server/internal/triffgonix/domain"
"github.com/DaniloMurer/triffgonix/server/internal/api/dto"
"github.com/DaniloMurer/triffgonix/server/internal/domain"
)

type Engine interface {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package engine

import (
"server/internal/triffgonix/domain"
"github.com/DaniloMurer/triffgonix/server/internal/domain"
"testing"
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// Package x01 is the implementation of the X01 dart game mode
package x01

import (
"server/internal/triffgonix/dart/engine"
"server/internal/triffgonix/domain"
"server/pkg/logging"
"github.com/DaniloMurer/triffgonix/server/internal/dart/engine"
"github.com/DaniloMurer/triffgonix/server/internal/domain"
"github.com/DaniloMurer/triffgonix/server/pkg/logging"
)

var logger = logging.NewLogger()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package x01

import (
"fmt"
"server/internal/triffgonix/dart/engine"
"server/internal/triffgonix/domain"
"github.com/DaniloMurer/triffgonix/server/internal/dart/engine"
"github.com/DaniloMurer/triffgonix/server/internal/domain"
"testing"
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package database

import (
"github.com/DaniloMurer/triffgonix/server/internal/models"
"gorm.io/driver/sqlite"
"gorm.io/gorm"
"server/internal/triffgonix/models"
)

var database *gorm.DB
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package database

import (
"github.com/DaniloMurer/triffgonix/server/internal/models"
"github.com/google/uuid"
"server/internal/triffgonix/models"
"testing"

"github.com/stretchr/testify/assert"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package domain

import "server/internal/triffgonix/models"
import (
"github.com/DaniloMurer/triffgonix/server/internal/models"
)

type Player struct {
Id uint `json:"id"`
Expand Down
File renamed without changes.

0 comments on commit 34c66fd

Please sign in to comment.