commit 2bae75cc3fc0e6fbe0933fbede1aefbd3b902a2c Author: Harvey Tindall Date: Thu Sep 5 12:56:51 2024 +0100 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. diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..54e7cfe --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +personal_access_token diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..838794e --- /dev/null +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..3516c17 --- /dev/null +++ b/go.sum @@ -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= diff --git a/main.go b/main.go new file mode 100644 index 0000000..691300c --- /dev/null +++ b/main.go @@ -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") +}