This repository has been archived by the owner on Oct 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 101
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
Showing
9 changed files
with
54 additions
and
14 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,3 @@ | ||
sudo docker-compose stop | ||
CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o AssassinGo | ||
sudo docker-compose up --build -d |
Binary file not shown.
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,25 @@ | ||
package config | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
) | ||
|
||
var ( | ||
// RootDir of your app | ||
RootDir = "./web" | ||
|
||
// SecretKey computes sg_token | ||
SecretKey string | ||
|
||
// DB addr and passwd. | ||
DB string | ||
) | ||
|
||
func init() { | ||
DB = fmt.Sprintf("%v:%v@tcp(mariadb:3306)/%v?charset=utf8", | ||
os.Getenv("DB_User"), | ||
os.Getenv("DB_Passwd"), | ||
os.Getenv("DB_Db")) | ||
SecretKey = os.Getenv("SecretKey") | ||
} |
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
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 |
---|---|---|
@@ -1,5 +1,7 @@ | ||
FROM alpine | ||
|
||
RUN apk --no-cache add ca-certificates | ||
|
||
ADD AssassinGo / | ||
|
||
CMD [ "./AssassinGo" ] |
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
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 |
---|---|---|
|
@@ -5,20 +5,20 @@ import ( | |
"fmt" | ||
"time" | ||
|
||
"../config" | ||
// | ||
_ "github.com/go-sql-driver/mysql" | ||
) | ||
|
||
var db *sql.DB | ||
|
||
func init() { | ||
db, _ = sql.Open("mysql", "ag:agpasswd@tcp(mariadb:3306)/ag?charset=utf8") | ||
db, _ = sql.Open("mysql", config.DB) | ||
|
||
// mysql image starts need time. | ||
for { | ||
err := db.Ping() | ||
if err == nil { | ||
fmt.Println("db ok!") | ||
break | ||
} | ||
fmt.Println(err) | ||
|
@@ -36,6 +36,7 @@ func init() { | |
email VARCHAR(64) NULL DEFAULT NULL, | ||
PRIMARY KEY (id) | ||
);`) | ||
db.Exec(`INSERT INTO users(username, password, email) values("admin","adminn","[email protected]");`) | ||
} | ||
|
||
func getPassword(username string) string { | ||
|
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
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