safe

package module
Version: v0.0.0-...-dbc6dc5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 14, 2017 License: MIT Imports: 1 Imported by: 0

README

Safe

  • Thread-safe for any value.

Installation

go get -u github.com/rafaeljesus/safe

Usage

package main

import "github.com/rafaeljesus/safe"

func main() {
  data := map[string]interface{}{"key": "value"}
  s := New(data)
  result, ok := s.Get().(map[string]interface{})
  if !ok {
    // wrong type
  }
  // do something
}

Contributing

  • Fork it
  • Create your feature branch (git checkout -b my-new-feature)
  • Commit your changes (git commit -am 'Add some feature')
  • Push to the branch (git push origin my-new-feature)
  • Create new Pull Request

Badges

Build Status Go Report Card Go Doc


GitHub @rafaeljesus  ·  Medium @_jesus_rafael  ·  Twitter @_jesus_rafael

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Safe

type Safe struct {
	// contains filtered or unexported fields
}

Safe wraps any value to a mutex.

func New

func New(value interface{}) *Safe

New create a new Safe instance.

func (*Safe) Get

func (s *Safe) Get() interface{}

Get returns the value in a thread-safe fashion.

func (*Safe) Set

func (s *Safe) Set(value interface{})

Set sets a new value in a thread-save fashion.

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL