Skip to content

Instantly share code, notes, and snippets.

@schadokar
Created November 6, 2022 16:52
Show Gist options
  • Save schadokar/dad822f2caaa430cc81c19c79df4b86c to your computer and use it in GitHub Desktop.
Save schadokar/dad822f2caaa430cc81c19c79df4b86c to your computer and use it in GitHub Desktop.
gochatapp main.go
package main
import (
"flag"
"fmt"
"log"
"gochatapp/pkg/httpserver"
"gochatapp/pkg/ws"
"github.com/joho/godotenv"
)
func init() {
// Load the environment file .env
err := godotenv.Load()
if err != nil {
log.Fatal("Unable to Load the env file.", err)
}
}
func main() {
server := flag.String("server", "", "http,websocket")
flag.Parse()
if *server == "http" {
fmt.Println("http server is starting on :8080")
httpserver.StartHTTPServer()
} else if *server == "websocket" {
fmt.Println("websocket server is starting on :8081")
ws.StartWebsocketServer()
} else {
fmt.Println("invalid server. Available server: http or websocket")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment