🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

github.com/maxsupermanhd/go-vmc/v764

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/maxsupermanhd/go-vmc/v764

v764.0.0-20240814201822-2fbab1c49213
Source
Go
Version published
Created
Source

NBT Go Reference

This package implements the Named Binary Tag format of Minecraft.

The API is very similar to the standard library encoding/json. (But fix some its problem) If you (high probability) have used that, it is easy to use this.

Supported Struct Tags and Options

  • nbt - The primary tag name. See below.
  • nbtkey - The key name of the field (Used to support commas , in tag names)

The nbt tag

In most cases, you only need this one to specify the name of the tag.

The format of nbt struct tag: <nbt tag>[,opt].

It's a comma-separated list of options. The first item is the name of the tag, and the rest are options.

Like this:

type MyStruct struct {
    Name string `nbt:"name"`
}

To tell the encoder not to encode a field, use -:

type MyStruct struct {
    Internal string `nbt:"-"`
}

To tell the encoder to skip the field if it is zero value, use omitempty:

type MyStruct struct {
    Name string `nbt:"name,omitempty"`
}

Fields typed []byte, []int32 and []int64 will be encoded as TagByteArray, TagIntArray and TagLongArray respectively by default. You can override this behavior by specifying encode them asTagList by using list:

type MyStruct struct {
    Data []byte `nbt:"data,list"`
}

The nbtkey tag

Common issue with JSON standard libraries: inability to specify keys containing commas for structures. (e.g {"a,b" : "c"})

So this is a workaround for that:

type MyStruct struct {
    AB string `nbt:",omitempty" nbtkey:"a,b"`
}

FAQs

Package last updated on 14 Aug 2024

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