Code Monkey home page Code Monkey logo

pinboard's Introduction

Package pinboard

GoDoc Go Report Card

Package pinboard implements a golang wrapper for the pinboard api.

Documentation

Please refer to GoDoc for up-to-date documentation.

pinboard's People

Contributors

imwally avatar markphelps avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

pinboard's Issues

json: cannot unmarshal number into Go struct field postsDatesResponse.dates of type string

I'm encountering an error when trying to use the PostDates function.

json: cannot unmarshal number into Go struct field postsDatesResponse.dates of type string

It looks like the response from https://api.pinboard.in/v1/posts/dates for the count field is actually a JSON integer, not a string.

This causes the library to error when trying to unmarshal the JSON response into postDatesResponse.dates which is a map[string]string. It seems this type should instead be a map[string]int

When doing a curl request to the API with my token, I get the following:

curl 'https://api.pinboard.in/v1/posts/dates?auth_token=REDACTED&format=json' -H 'accept: application/json'
{
  "user": "me",
  "tag": "",
  "dates": {
    "2021-08-28": 2,
    "2021-08-25": 1,
    "2021-08-05": 1,
    "2021-07-26": 1,
    "2021-07-08": 2,
    "2021-06-15": 1,
    "2021-05-30": 1,
    "2021-02-21": 1,
    "2020-10-12": 1,
    "2020-10-10": 2,
    "2020-10-02": 87
  }
}

Bad parsing: posts without tags get an empty tag

Hello Wally,

I found a bug :)

tags := strings.Split(p.Tags, " ")

If p.tags equals an empty string, then tags equals []string{""} whereas it should be equal to []string. This is due to the way strings.Split works.

Here is the fix;

var tags []string
if p.Tags != "" {
    tags = strings.Split(p.Tags, " ")
} else {
    tags = make([]string, 0, 0)
}

Thank you for this package,
Have a good day

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.