Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Socket
Sign inDemoInstall

github.com/edwingeng/live

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/edwingeng/live


Version published
Created
Source

Overview

live.Data is a handy general-purpose data wrapper, which solves the problem that the same data type in different versions of a plugin are actually not the same at runtime. It is designed to work with hotswap, which provides a solution for reloading your go code without restarting your server, interrupting or blocking any ongoing procedure.

Getting Started

go get -u github.com/edwingeng/live

Usage

type questInfo1 struct {
    ID   int64
    Name string
    Done bool
}

q1 := questInfo1{
    ID:   5848,
    Name: "Of Love and Family",
}

liveObj := WrapObject(&q1)

// 2000 years later...

type questInfo2 struct {
    ID   int64
    Name string
    Desc string
    Done bool
}

var q2 questInfo2
q2.Desc = "<>"
liveObj.MustUnwrapObject(&q2)
fmt.Printf("ID: %v\n", q2.ID)
fmt.Printf("Name: %v\n", q2.Name)
fmt.Printf("Desc: %v\n", q2.Desc)
fmt.Printf("Done: %v\n", q2.Done)

// Output:
// ID: 5848
// Name: Of Love and Family
// Desc: <>
// Done: false

Unsupported Types

  • uintptr
  • func
  • interface{}, as known as any
  • unsafe.Pointer

FAQ

  • Is it allowed for a struct to have a field of an unsupported type?

Yes. The field tag, live:"true", is designed for that.

type example struct {
    x func() `live:"true"`
}

FAQs

Package last updated on 20 Oct 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc