-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 8aa79b8
Showing
9 changed files
with
851 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
use flake |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: Test building | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: '1.22.5' | ||
|
||
- name: Build | ||
run: go build -v ./... | ||
|
||
- name: Install Nix | ||
uses: cachix/install-nix-action@v25 | ||
with: | ||
nix_path: nixpkgs=channel:nixos-unstable | ||
|
||
- run: nix build .# --show-trace |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.direnv | ||
result |
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# 🤖 Gap - WIP | ||
|
||
Gap is a modular REST API with which you can interact to view, add and remove content. | ||
It's a project for practicing my Go skills so there's nothing really fancy, just me learning... | ||
|
||
## 📑 Features | ||
|
||
You can launch it from the command line and add some arguments. | ||
```bash | ||
$ gap -h | ||
Usage: gap [-p PORT | -h] | ||
$ gap -p 8080 | ||
Server is running at 'http://localhost:8080' | ||
``` | ||
|
||
## 🔨 Building | ||
|
||
#### 🐁 Go | ||
```bash | ||
$ go build . | ||
``` | ||
|
||
#### ❄️ Nix | ||
```bash | ||
$ nix build .# | ||
``` |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
description = "A development environment for this go project"; | ||
|
||
inputs = { | ||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; | ||
flake-parts.url = "github:hercules-ci/flake-parts"; | ||
}; | ||
|
||
outputs = inputs: | ||
inputs.flake-parts.lib.mkFlake { inherit inputs; } { | ||
systems = [ "x86_64-linux" "aarch64-linux" ]; | ||
perSystem = { pkgs, ... }: { | ||
devShells.default = pkgs.mkShell { | ||
packages = with pkgs; [ go air delve ]; | ||
}; | ||
packages.default = pkgs.buildGoModule { | ||
name = "gap"; | ||
src = ./.; | ||
version = "git"; | ||
vendorHash = null; | ||
}; | ||
}; | ||
}; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module github.com/sh-koh/gap | ||
|
||
go 1.22.5 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"net/http" | ||
"os" | ||
"strconv" | ||
) | ||
|
||
func main() { | ||
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { | ||
w.Write([]byte("Welcome to the main page!")) | ||
}) | ||
http.HandleFunc("/test", func(w http.ResponseWriter, r *http.Request) { | ||
w.Write([]byte("This page is for testing.")) | ||
}) | ||
|
||
for i, arg := range os.Args { | ||
if i != 0 { | ||
switch arg { | ||
case "-p": | ||
if len(os.Args) > i+1 { | ||
p, _ := strconv.Atoi(os.Args[i+1]) | ||
fmt.Printf("Server is running at 'http://localhost:%d'\n", p) | ||
http.ListenAndServe(fmt.Sprintf(":%d", p), nil) | ||
} else { | ||
fmt.Println("You need to provide an argument to '-d'") | ||
} | ||
case "-h": | ||
fmt.Printf("Usage: %s [-p PORT | -h]\n", os.Args[0]) | ||
} | ||
} | ||
} | ||
} |