10
.github/workflows/go-presubmit.yml
vendored
10
.github/workflows/go-presubmit.yml
vendored
@ -13,13 +13,13 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
go-version: ['1.17', '1.18', '1.19']
|
||||
go-version: ['1.19', '1.20', '1.21']
|
||||
steps:
|
||||
- name: Install Go ${{ matrix.go-version }}
|
||||
uses: actions/setup-go@v3
|
||||
uses: actions/setup-go@v4
|
||||
with:
|
||||
go-version: ${{ matrix.go-version }}
|
||||
- uses: actions/checkout@v3
|
||||
- uses: creachadair/go-presubmit-action@v1
|
||||
- uses: actions/checkout@v4
|
||||
- uses: creachadair/go-presubmit-action@v2
|
||||
with:
|
||||
staticcheck-version: "2022.1.3"
|
||||
staticcheck-version: "2023.1.6"
|
||||
|
16
.github/workflows/goreleaser.yml
vendored
16
.github/workflows/goreleaser.yml
vendored
@ -17,31 +17,29 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v2
|
||||
uses: actions/setup-go@v4
|
||||
with:
|
||||
go-version: 1.17
|
||||
go-version: 1.21
|
||||
|
||||
- name: Run GoReleaser release (SKIP publish)
|
||||
uses: goreleaser/goreleaser-action@v3
|
||||
uses: goreleaser/goreleaser-action@v5
|
||||
if: startsWith(github.ref, 'refs/tags/') != true
|
||||
with:
|
||||
distribution: goreleaser
|
||||
version: latest
|
||||
args: release --rm-dist --skip-publish
|
||||
args: release --clean --skip=publish --snapshot
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Run GoReleaser release
|
||||
uses: goreleaser/goreleaser-action@v3
|
||||
uses: goreleaser/goreleaser-action@v5
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
with:
|
||||
distribution: goreleaser
|
||||
version: latest
|
||||
args: release --rm-dist
|
||||
args: release --clean
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
10
gauth.go
10
gauth.go
@ -113,6 +113,10 @@ func addCode(accountName string) {
|
||||
// Check for encryption and ask for password if necessary
|
||||
_, isEncrypted, err := gauth.ReadConfigFile(cfgPath)
|
||||
|
||||
if err != nil {
|
||||
log.Fatalf("Reading config: %v", err)
|
||||
}
|
||||
|
||||
password, err := []byte(nil), nil
|
||||
|
||||
if isEncrypted {
|
||||
@ -169,13 +173,17 @@ func removeCode(accountName string) {
|
||||
// Check for encryption and ask for password if necessary
|
||||
_, isEncrypted, err := gauth.ReadConfigFile(cfgPath)
|
||||
|
||||
if err != nil {
|
||||
log.Fatalf("Reading config: %v", err)
|
||||
}
|
||||
|
||||
password, err := []byte(nil), nil
|
||||
|
||||
if isEncrypted {
|
||||
password, err = getPassword()
|
||||
|
||||
if err != nil {
|
||||
log.Fatalf("reading passphrase: %v", err)
|
||||
log.Fatalf("Reading passphrase: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"hash"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@ -78,7 +78,7 @@ func CodesAtTimeStep(u *otpauth.URL, timeStep uint64) (prev, curr, next string,
|
||||
// ReadConfigFile reads the config file at path and returns its contents and
|
||||
// whether it is encrypted or not
|
||||
func ReadConfigFile(path string) ([]byte, bool, error) {
|
||||
data, err := ioutil.ReadFile(path)
|
||||
data, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return nil, false, err
|
||||
}
|
||||
@ -184,7 +184,7 @@ func WriteConfigFile(path string, passwd []byte, newConfig []byte) error {
|
||||
newConfig = append(saltedPrefix, newConfig...)
|
||||
}
|
||||
|
||||
err = ioutil.WriteFile(path, newConfig, 0)
|
||||
err = os.WriteFile(path, newConfig, 0)
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("writing config: %v", err)
|
||||
|
Reference in New Issue
Block a user