gen-atomicwrapper

command
v0.8.7 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2025 License: Unlicense, MIT Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

gen-atomicwrapper generates wrapper types around other atomic types.

It supports plugging in functions which convert the value inside the atomic type to the user-facing value. For example,

Given, atomic.Value and the functions,

func packString(string) enveloper{}
func unpackString(enveloper{}) string

We can run the following command:

gen-atomicwrapper -name String -wrapped Value \
  -type string -pack fromString -unpack tostring

This wil generate approximately,

type String struct{ v Value }

func (s *String) Load() string {
  return unpackString(v.Load())
}

func (s *String) Store(s string) {
  return s.v.Store(packString(s))
}

The packing/unpacking logic allows the stored value to be different from the user-facing value.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL