go mod init and secrets file

secret personal access token stored in ./personal_access_token, added to
.gitignore. a bit of a start on the program.
This commit is contained in:
Harvey Tindall 2024-09-05 12:56:51 +01:00
commit 2bae75cc3f
Signed by: hrfee
GPG Key ID: BBC65952848FB1A2
4 changed files with 51 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
personal_access_token

5
go.mod Normal file
View File

@ -0,0 +1,5 @@
module git.hrfee.pw/hrfee/discogs-pricer
go 1.22.4
require github.com/irlndts/go-discogs v0.3.6 // indirect

2
go.sum Normal file
View File

@ -0,0 +1,2 @@
github.com/irlndts/go-discogs v0.3.6 h1:3oIJEkLGQ1ffJcoo6wvtawPI4/SyHoRpnu25Y51U4wg=
github.com/irlndts/go-discogs v0.3.6/go.mod h1:UVQ05FdCzH4P/usnSxQDh77QYE37HvmPnSCgogioljo=

43
main.go Normal file
View File

@ -0,0 +1,43 @@
package main
import (
"errors"
"fmt"
"os"
"strings"
"github.com/irlndts/go-discogs"
)
var (
CURRENCY = "GBP"
USER_AGENT = "discogs-pricer/0.0 +https://git.hrfee.pw/hrfee/discogs-pricer"
)
/*type ServiceWriter interface {
WriteRow(svcID string, name string, price string, purchaseDate time.Time, notes string)
}*/
type Client struct {
c discogs.Discogs
}
func NewClient(currency string, userAgent string, token string) (*Client, error) {
client := Client{}
var err error
client.c, err = discogs.New(&discogs.Options{
UserAgent: userAgent,
Currency: currency,
Token: token,
})
return &client, err
}
func main() {
token, err := os.ReadFile("personal_access_token")
if err != nil {
panic(errors.New("no token found in ./personal_access_token"))
}
c, err := NewClient(CURRENCY, USER_AGENT, strings.TrimSuffix(string(token), "\n"))
fmt.Println("vim-go")
}