Skip to content
Snippets Groups Projects
Select Git revision
  • ba384f5b5adecacf4ea59a45455b1638e2da7a29
  • master default protected
  • renovate/golang.org-x-net-0.x
  • renovate/golang.org-x-crypto-0.x
  • renovate/git.autistici.org-ai3-go-common-digest
  • renovate/github.com-miekg-dns-1.x
  • renovate/github.com-prometheus-client_golang-1.x
  • v3
  • v2
9 results

valid_cert.go

Blame
    • ale's avatar
      69d65dfa
      Refactor of the code · 69d65dfa
      ale authored
      Add dns-01 support, make the code more readable, add a testing
      mode that will generate self-signed certificates (for test
      environments that are not reachable from outside).
      69d65dfa
      History
      Refactor of the code
      ale authored
      Add dns-01 support, make the code more readable, add a testing
      mode that will generate self-signed certificates (for test
      environments that are not reachable from outside).
    intern.go 790 B
    // Package intern interns strings.
    // Interning is best effort only.
    // Interned strings may be removed automatically
    // at any time without notification.
    // All functions may be called concurrently
    // with themselves and each other.
    package intern
    
    import "sync"
    
    var (
    	pool sync.Pool = sync.Pool{
    		New: func() interface{} {
    			return make(map[string]string)
    		},
    	}
    )
    
    // String returns s, interned.
    func String(s string) string {
    	m := pool.Get().(map[string]string)
    	c, ok := m[s]
    	if ok {
    		pool.Put(m)
    		return c
    	}
    	m[s] = s
    	pool.Put(m)
    	return s
    }
    
    // Bytes returns b converted to a string, interned.
    func Bytes(b []byte) string {
    	m := pool.Get().(map[string]string)
    	c, ok := m[string(b)]
    	if ok {
    		pool.Put(m)
    		return c
    	}
    	s := string(b)
    	m[s] = s
    	pool.Put(m)
    	return s
    }