Created
November 6, 2022 16:52
-
-
Save schadokar/dad822f2caaa430cc81c19c79df4b86c to your computer and use it in GitHub Desktop.
gochatapp main.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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