Code Monkey home page Code Monkey logo

dontgo's Introduction

DontGo

GoDoc

An unofficial client for using dontpad.com with go. Create temporary online persistence.

dontpad.com

Dontpad is an online and easily shareable notepad. You can create and edit pages using any identifier simply by accessing dontpad.com/{identifier}

Installation

You can install with a simple go get
go get github.com/lucp2/dontgo

Usage

There are basically four methods you can call. All are exemplified here and documented in godoc.

package main

import(
    "github.com/lucp2/dontgo"
    "fmt"
)

func main() {
	// first lets write something in a page with the identifier "dontgo_test"
	// you can pass variables with any type to be written. With we can not simply convert it
	// to string, we will transform it into json.
	err := dontgo.Write("dontgo_test", "hello world")

	// now with access dontpad.com/dontgo_test we will see our "hello world" there

	// if there is anything wrong, we will tell you. 
	// What can go wrong are basically connection problems
	// or we couldn't convert what you passed to string (what did you pass?)
	if err != nil {
		fmt.Println(err)
		return
	}

	// we can also retrieve what we've just written
	a := dontgo.Read("dontgo_test")
	fmt.Println(a) //will print "hello world"

	// if there is anything wrong with the read function (such as connection), it will panic.
	// this is proposital, allowing you to use it directly as a value.
	// but if you don't this to happen, use ReadNoPanic instead.

	a, err = dontgo.ReadNoPanic("dontgo_test")
	if err != nil {
		// now you can treat it
		fmt.Println(err)
		return
	}
	fmt.Println(a) //will print "hello world"

	// the write function will overwrite anything that is already in the identifier's page.
	// if that is not your intention, use Append.
	err = dontgo.Append("dontgo_test", ", how you doing?")
	if err != nil {
		fmt.Println(err)
		return
	}

	// and if we read it again now
	a = dontgo.Read("dontgo_test")
	fmt.Println(a) //will print "hello world, how you doing?"

	// we can also clear a page simply by calling Clear
	err = dontgo.Clear("dontgo_test")
	if err != nil {
		fmt.Println(err)
		return
	}

	// and if we read it again now
	a = dontgo.Read("dontgo_test")
	fmt.Println(a) //will print nothing
}

Warning

Do not ever use this in production. First because this is unofficial and there is no guarantee that dontpad will not change the way they store the contents. And second because anyone is able to overwrite the identifiers without any authorization.

dontgo's People

Contributors

luccaportes avatar

Stargazers

 avatar

Watchers

 avatar  avatar

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.