discogs-pricer/main.go
Harvey Tindall 2bae75cc3f
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.
2024-09-05 12:56:51 +01:00

44 lines
891 B
Go

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")
}