Documentation ¶
Overview ¶
Package bang implements browser-launching URL shortcuts.
Index ¶
- Variables
- func Filter(vs map[string]Bang, f func(string) bool) map[string]Bang
- func ListBangs(bangs map[string]Bang) string
- func SliceToMap(slice []Bang) (bangs map[string]Bang)
- type Bang
- func (*Bang) Descriptor() ([]byte, []int)
- func (m *Bang) GetDescription() string
- func (m *Bang) GetEscapeMethod() Bang_EscapeMethod
- func (m *Bang) GetFormat() string
- func (m *Bang) GetName() string
- func (*Bang) ProtoMessage()
- func (m *Bang) Reset()
- func (m *Bang) String() string
- func (b *Bang) URL(q string) string
- func (m *Bang) XXX_DiscardUnknown()
- func (m *Bang) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *Bang) XXX_Merge(src proto.Message)
- func (m *Bang) XXX_Size() int
- func (m *Bang) XXX_Unmarshal(b []byte) error
- type Bang_EscapeMethod
Constants ¶
This section is empty.
Variables ¶
View Source
var Bang_EscapeMethod_name = map[int32]string{
0: "QUERY_ESCAPE",
1: "PASS_THROUGH",
2: "PATH_ESCAPE",
}
View Source
var Bang_EscapeMethod_value = map[string]int32{
"QUERY_ESCAPE": 0,
"PASS_THROUGH": 1,
"PATH_ESCAPE": 2,
}
View Source
var Bangs = map[string]Bang{}
Bangs is the registration list of all Bangs. We use a map[string] here for faster lookups at runtime than digging through slices.
Functions ¶
func Filter ¶
Filter filters a map of Bangs based on a predicate.
fmt.Println(Filter(Bangs, func(v string) bool { return strings.Contains(strings.ToLower(v), strings.ToLower("Bing")) }))
func SliceToMap ¶
SliceToMap returns a map of Bangs based on the input slice's Bangs' names.
Types ¶
type Bang ¶
type Bang struct { // Name of the Bang, which is used as its ID. Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` // Format of the Bang, where '{{{s}}}' will be substituted with the escaped // query string. Format string `protobuf:"bytes,2,opt,name=format,proto3" json:"format,omitempty"` // Description is a summary of the Bang. Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"` EscapeMethod Bang_EscapeMethod `` /* 126-byte string literal not displayed */ XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func MapToNamedBangs ¶
MapToNamedBangs returns a slice of Bangs with their names set according to keys from an input map.
func (*Bang) Descriptor ¶
func (*Bang) GetDescription ¶
func (*Bang) GetEscapeMethod ¶
func (m *Bang) GetEscapeMethod() Bang_EscapeMethod
func (*Bang) ProtoMessage ¶
func (*Bang) ProtoMessage()
func (*Bang) XXX_DiscardUnknown ¶
func (m *Bang) XXX_DiscardUnknown()
func (*Bang) XXX_Unmarshal ¶
type Bang_EscapeMethod ¶
type Bang_EscapeMethod int32
EscapeMethod is the type of escaping to be used when escaping non-URL safe characters, like spaces and quotes.
const ( // Escapes the input with url.QueryEscape: "cat pictures" => "cat+pictures" Bang_QUERY_ESCAPE Bang_EscapeMethod = 0 // Does no escaping: "cat pictures" => "cat pictures" Bang_PASS_THROUGH Bang_EscapeMethod = 1 // Escapes the input with url.PathEscape: "cat pictures" => "cat%20pictures" Bang_PATH_ESCAPE Bang_EscapeMethod = 2 )
func (Bang_EscapeMethod) EnumDescriptor ¶
func (Bang_EscapeMethod) EnumDescriptor() ([]byte, []int)
func (Bang_EscapeMethod) String ¶
func (x Bang_EscapeMethod) String() string
Click to show internal directories.
Click to hide internal directories.