Skip to content

Commit 93c59e2

Browse files
Add basic GUI
1 parent 90db537 commit 93c59e2

7 files changed

Lines changed: 1089 additions & 13 deletions

File tree

Makefile

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,56 @@ VERSION ?= dev
44

55
GO := go
66
GOFLAGS := -trimpath
7-
LDFLAGS := -s -w
7+
CGO_ENABLED := 0
8+
DEV_LDFLAGS :=
9+
PROD_LDFLAGS := -s -w
810

9-
.PHONY: all build build-linux build-macos build-windows build-wasm build-all clean
11+
.PHONY: all build build-linux build-macos build-windows build-all \
12+
build-prod build-linux-prod build-macos-prod build-windows-prod build-all-prod clean
1013

1114
all: build-all
1215

1316
build: ## Build for the current platform
14-
$(GO) build $(GOFLAGS) -ldflags "$(LDFLAGS)" -o $(BINARY_NAME) .
17+
CGO_ENABLED=$(CGO_ENABLED) $(GO) build $(GOFLAGS) -ldflags "$(DEV_LDFLAGS)" -o $(BINARY_NAME) .
18+
19+
build-prod: ## Build stripped production binary for the current platform
20+
CGO_ENABLED=$(CGO_ENABLED) $(GO) build $(GOFLAGS) -ldflags "$(PROD_LDFLAGS)" -o $(BINARY_NAME) .
1521

1622
build-linux: ## Build static Linux binary (amd64)
1723
mkdir -p $(DIST_DIR)
18-
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GO) build $(GOFLAGS) -ldflags "$(LDFLAGS)" -o $(DIST_DIR)/$(BINARY_NAME)-linux-amd64 .
24+
CGO_ENABLED=$(CGO_ENABLED) GOOS=linux GOARCH=amd64 $(GO) build $(GOFLAGS) -ldflags "$(DEV_LDFLAGS)" -o $(DIST_DIR)/$(BINARY_NAME)-linux-amd64 .
25+
26+
build-linux-prod: ## Build stripped static Linux binary (amd64)
27+
mkdir -p $(DIST_DIR)
28+
CGO_ENABLED=$(CGO_ENABLED) GOOS=linux GOARCH=amd64 $(GO) build $(GOFLAGS) -ldflags "$(PROD_LDFLAGS)" -o $(DIST_DIR)/$(BINARY_NAME)-linux-amd64 .
1929

20-
build-macos: ## Build macOS binary (amd64 + arm64)
30+
build-macos: ## Build static macOS binary (amd64 + arm64)
2131
mkdir -p $(DIST_DIR)
22-
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 $(GO) build $(GOFLAGS) -ldflags "$(LDFLAGS)" -o $(DIST_DIR)/$(BINARY_NAME)-darwin-amd64 .
23-
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 $(GO) build $(GOFLAGS) -ldflags "$(LDFLAGS)" -o $(DIST_DIR)/$(BINARY_NAME)-darwin-arm64 .
32+
CGO_ENABLED=$(CGO_ENABLED) GOOS=darwin GOARCH=amd64 $(GO) build $(GOFLAGS) -ldflags "$(DEV_LDFLAGS)" -o $(DIST_DIR)/$(BINARY_NAME)-darwin-amd64 .
33+
CGO_ENABLED=$(CGO_ENABLED) GOOS=darwin GOARCH=arm64 $(GO) build $(GOFLAGS) -ldflags "$(DEV_LDFLAGS)" -o $(DIST_DIR)/$(BINARY_NAME)-darwin-arm64 .
2434

25-
build-windows: ## Build Windows binary (amd64)
35+
build-macos-prod: ## Build stripped static macOS binaries (amd64 + arm64)
2636
mkdir -p $(DIST_DIR)
27-
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 $(GO) build $(GOFLAGS) -ldflags "$(LDFLAGS)" -o $(DIST_DIR)/$(BINARY_NAME)-windows-amd64.exe .
37+
CGO_ENABLED=$(CGO_ENABLED) GOOS=darwin GOARCH=amd64 $(GO) build $(GOFLAGS) -ldflags "$(PROD_LDFLAGS)" -o $(DIST_DIR)/$(BINARY_NAME)-darwin-amd64 .
38+
CGO_ENABLED=$(CGO_ENABLED) GOOS=darwin GOARCH=arm64 $(GO) build $(GOFLAGS) -ldflags "$(PROD_LDFLAGS)" -o $(DIST_DIR)/$(BINARY_NAME)-darwin-arm64 .
2839

29-
build-wasm: ## Build WebAssembly binary (js/wasm)
40+
build-windows: ## Build static Windows binary (amd64)
3041
mkdir -p $(DIST_DIR)
31-
GOOS=js GOARCH=wasm $(GO) build $(GOFLAGS) -ldflags "$(LDFLAGS)" -o $(DIST_DIR)/$(BINARY_NAME)-js-wasm.wasm .
42+
CGO_ENABLED=$(CGO_ENABLED) GOOS=windows GOARCH=amd64 $(GO) build $(GOFLAGS) -ldflags "$(DEV_LDFLAGS)" -o $(DIST_DIR)/$(BINARY_NAME)-windows-amd64.exe .
43+
44+
build-windows-prod: ## Build stripped static Windows binary (amd64)
45+
mkdir -p $(DIST_DIR)
46+
CGO_ENABLED=$(CGO_ENABLED) GOOS=windows GOARCH=amd64 $(GO) build $(GOFLAGS) -ldflags "$(PROD_LDFLAGS)" -o $(DIST_DIR)/$(BINARY_NAME)-windows-amd64.exe .
47+
48+
build-all: ## Build all target platforms (fully static binaries)
49+
$(MAKE) build-linux
50+
$(MAKE) build-macos
51+
$(MAKE) build-windows
3252

33-
build-all: build-linux build-macos build-windows build-wasm ## Build all target platforms
53+
build-all-prod: ## Build all stripped target platforms (fully static binaries)
54+
$(MAKE) build-linux-prod
55+
$(MAKE) build-macos-prod
56+
$(MAKE) build-windows-prod
3457

3558
clean: ## Remove build artifacts
3659
rm -rf $(DIST_DIR)

go.mod

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
module steg-go
22

3-
go 1.21
3+
go 1.23.8
4+
5+
require github.com/gorilla/websocket v1.5.3

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
2+
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=

main.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,28 @@ import (
99
"image/png"
1010
"os"
1111

12+
"steg-go/server"
1213
"steg-go/stego"
1314
)
1415

1516
func main() {
17+
// Check if any arguments were provided
18+
if len(os.Args) == 1 {
19+
// No arguments - launch web server
20+
port := 0 // Use OS-assigned port (any available)
21+
s := server.NewServer(port, embedFS)
22+
if err := s.Run(); err != nil {
23+
fmt.Fprintf(os.Stderr, "Server error: %v\n", err)
24+
os.Exit(1)
25+
}
26+
return
27+
}
28+
29+
// CLI mode
30+
runCLI()
31+
}
32+
33+
func runCLI() {
1634
var inputImage string
1735
var output string
1836
var files []string
@@ -33,6 +51,7 @@ func main() {
3351
fmt.Fprintf(os.Stderr, "Usage: %s -i <input_image> [-f <file1> -f <file2> ...] -o <output>\n", os.Args[0])
3452
fmt.Fprintf(os.Stderr, "\nEncode mode: -i <image> -f <files...> -o <output.png>\n")
3553
fmt.Fprintf(os.Stderr, "Extract mode: -i <image> -o <output_directory>\n")
54+
fmt.Fprintf(os.Stderr, "\nGUI mode: Run without any arguments\n")
3655
os.Exit(1)
3756
}
3857

0 commit comments

Comments
 (0)