Coder Social home page Coder Social logo

gdata's Introduction

gdata

Build Status PkgGoDev

A gamedata package that provides convenient cross-platform storage for games.

Some examples of such gamedata that you might want to store:

  • Game settings
  • Save states
  • Replays
  • Pluging/mods metadata

This package was made with Ebitengine in mind, but it should be usable with any kind of a game engine for Go.

Platforms supported:

  • Windows (file system, AppData)
  • Linux (file system, ~/.local/share)
  • MacOS (file system, ~/.local/share)
  • Android (file system, app data directory)
  • Browser/wasm (local storage)

This library tries to use the most conventional app data folder for every platform.

It provides a simple key-value style API. It can be considered to be a platform-agnostic localStorage.

This package was part of my game development framework which I used in all of my Go-powered games. Now I'm feel like it's ready to become a part of the ecosystem.

Installation

go get github.com/quasilyte/gdata

Quick Start

package main

import (
	"fmt"

	"github.com/quasilyte/gdata"
)

func main() {
	// m is a data manager; treat it as a connection to a filesystem.
	m, err := gdata.Open(gdata.Config{
		AppName: "my_game",
	})
	if err != nil {
		panic(err)
	}

	if err := m.SaveItem("save.data", []byte("mydata")); err != nil {
		panic(err)
	}

	result, err := m.LoadItem("save.data")
	if err != nil {
		panic(err)
	}
	fmt.Println("=>", string(result)) // "mydata"

	fmt.Println("exists?", m.ItemExists("save.data")) // true
}

gdata's People

Contributors

quasilyte avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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.