Discover Packages
github.com/projectdiscovery/utils
ptr
package
Version:
v0.4.5
Opens a new window with list of versions in this module.
Published: Dec 30, 2024
License: MIT
Opens a new window with license information.
Imports: 0
Opens a new window with list of imports.
Imported by: 17
Opens a new window with list of known importers.
Documentation
Documentation
¶
Of returns pointer of a given generic type
Example:
var v int
var p = ptr.Of(v)
Safe dereferences safely a pointer
- if the pointer is nil => returns the zero value of the type of the pointer if nil
- if the pointer is not nil => returns the dereferenced pointer
Example:
var v *int
var x = ptr.Safe(v)
func When[T any ](v T, condition bool ) *T
When returns pointer of a given generic type
- if the condition is false => returns nil
- if the condition is true => returns pointer of the value
Example:
var v bool
var p = ptr.When(v, v != false)
Source Files
¶
Click to show internal directories.
Click to hide internal directories.