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:
commit
2bae75cc3f
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
personal_access_token
|
5
go.mod
Normal file
5
go.mod
Normal 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
2
go.sum
Normal 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
43
main.go
Normal 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")
|
||||
}
|
Loading…
Reference in New Issue
Block a user