
Research
Security News
The Growing Risk of Malicious Browser Extensions
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
github.com/jimtwn/stringer
This program is a drop-in replacement for Go's commonly used stringer tool.
In addition to generating String() string
implementations for individual
constants, this version also works with bit flag sets.
For instance:
type T uint
const (
Foo T = 1 << iota
Bar
Baz
)
When invoking Foo.String()
, we should get "Foo"
. When invoking (Foo|Bar).String()
the old stringer tool will only print a numeric value: "T(3)"
. In our case, we will get the expected: "Foo, Bar"
. Unknown values in a bit flag set will still be presented in the "T(3)"
form:
(T(1<<12) | Baz).String() == "Baz, T(4096)"
$ go get -u github.com/hexaflex/stringer
In the go source file, use a go:generate
statement to have the tool generate the required code. This tool recognizes all the existing options Go's stringer recognizes.
//go:generate stringer -type=MyType
In order to treat a type as a bit flag set, use:
//go:generate stringer -flags -type=MyType
Copyright 2014 The Go Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
FAQs
Unknown package
Did you know?
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.
Research
Security News
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
Research
Security News
An in-depth analysis of credential stealers, crypto drainers, cryptojackers, and clipboard hijackers abusing open source package registries to compromise Web3 development environments.
Security News
pnpm 10.12.1 introduces a global virtual store for faster installs and new options for managing dependencies with version catalogs.