Skip to content

Commit 6e1ce07

Browse files
committed
chore: add build instruction
Important note about crypto package: - We were planning on just using -ldflags to pass privkey and passphrase, but that didn't work. So now we are using build tags. - the var privkey and passphrase are now moved to placeholder and made constant.
1 parent 01bfcb0 commit 6e1ce07

File tree

4 files changed

+36
-3
lines changed

4 files changed

+36
-3
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
### our own ignored files ###
2+
crypto/credentials.go
3+
14
### dotenv ###
25
.env
36

README.md

+27-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,28 @@
11
# ksau-go
2-
The original ksau. Now written in Go!
2+
3+
## Development
4+
> Table of Content
5+
> - [Building the Project](#Building-the-Project)
6+
7+
### Building the Project
8+
To build `ksau-go`, there's one important detail to note. You will need to create
9+
**crypto/credentials.go**. Then, set constants named `privkey` which is a secret pgp
10+
key, and `passphrase` which is the passphrase for that secret pgp key (if any),
11+
else set an empty const.
12+
13+
Follow this template:
14+
```go
15+
//go:build credentials
16+
package crypto
17+
18+
const privkey string = `mykey`
19+
const passphrase string = "mypassphrase"
20+
```
21+
> [!NOTE]
22+
> The `//go:build credentials` directive is **not** optional. do **not** omit it.
23+
24+
Then, run the following to build:
25+
```bash
26+
go build -tags credentials
27+
```
28+

crypto/algo.go

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ package crypto
33
import "github.com/ProtonMail/gopenpgp/v3/crypto"
44

55
var pgp *crypto.PGPHandle = crypto.PGP()
6-
var passphrase string = "placeholder"
7-
var privkey string = "placeholder"
86

97
func getPrivateKey() *crypto.Key {
108
key, err := crypto.NewPrivateKeyFromArmored(privkey, []byte(passphrase))

crypto/placeholder.go

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//go:build !credentials
2+
3+
package crypto
4+
5+
const passphrase string = "placeholder"
6+
const privkey string = "placeholder"

0 commit comments

Comments
 (0)