New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

gitlab.com/mjwhitta/safety

Package Overview
Dependencies
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gitlab.com/mjwhitta/safety

Source
Go Modules
Version
v1.11.1
Version published
Created
Source

safety

🍪 Buy me a cookie

Go Report Card

What is this?

This Go module provides some thread-safe utilities.

How to install

Open a terminal and run the following:

$ go get --ldflags="-s -w" --trimpath -u gitlab.com/mjwhitta/safety

Usage

package main

import (
    hl "gitlab.com/mjwhitta/hilighter"
    "gitlab.com/mjwhitta/safety"
)

func main() {
    var m *safety.Map = safety.NewMap()
    var s *safety.Set = safety.NewSet()
    var sl *safety.Slice = safety.NewSlice()

    // Maps
    m.Put("a", "asdf")
    m.Put("b", "blah")
    m.Put("s", "stop")
    m.Put("t", "test")

    m.Range(
        func(k, v interface{}) bool {
            switch v.(string) {
            case "stop":
                return true
            }

            hl.Printf("%s = %s\n", k.(string), v.(string))
            return false
        },
    )

    hl.Println(m.Keys())

    // Sets
    s.Add("asdf")
    s.Add("blah")
    s.Add("stop")
    s.Add("test")

    s.Range(
        func(entry interface{}) bool {
            switch entry.(string) {
            case "stop":
                return true
            }

            hl.Printf("Set includes: %s\n", entry.(string))
            return false
        },
    )

    hl.Println(s.Get())

    // Slices
    sl.Append("asdf")
    sl.Append("blah")
    sl.Append("stop")
    sl.Append("test")

    sl.Range(
        func(i int, v interface{}) bool {
            switch v.(string) {
            case "stop":
                return true
            }

            hl.Printf("Slice %d: %s\n", i, v.(string))
            return false
        },
    )

    hl.Println(sl.Get(0))
}
  • Source

FAQs

Package last updated on 04 Aug 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