go-lemmy/examples/basic/main.go

32 lines
463 B
Go
Raw Normal View History

2023-01-08 08:47:32 +00:00
package main
import (
"context"
2023-04-21 02:27:38 +00:00
"go.elara.ws/go-lemmy"
2023-01-08 08:47:32 +00:00
)
func main() {
ctx := context.Background()
2023-10-05 20:20:12 +00:00
c, err := lemmy.New("https://lemmy.ml")
2023-01-08 08:47:32 +00:00
if err != nil {
panic(err)
}
err = c.ClientLogin(ctx, lemmy.Login{
2023-01-08 08:47:32 +00:00
UsernameOrEmail: "user@example.com",
Password: `TestPwd`,
})
if err != nil {
panic(err)
}
_, err = c.SaveUserSettings(ctx, lemmy.SaveUserSettings{
BotAccount: lemmy.NewOptional(true),
2023-01-08 08:47:32 +00:00
})
if err != nil {
panic(err)
}
}