id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
26,400 | stripe/stripe-go | applepaydomain/client.go | Del | func (c Client) Del(id string, params *stripe.ApplePayDomainParams) (*stripe.ApplePayDomain, error) {
path := stripe.FormatURLPath("/v1/apple_pay/domains/%s", id)
domain := &stripe.ApplePayDomain{}
err := c.B.Call(http.MethodDelete, path, c.Key, params, domain)
return domain, err
} | go | func (c Client) Del(id string, params *stripe.ApplePayDomainParams) (*stripe.ApplePayDomain, error) {
path := stripe.FormatURLPath("/v1/apple_pay/domains/%s", id)
domain := &stripe.ApplePayDomain{}
err := c.B.Call(http.MethodDelete, path, c.Key, params, domain)
return domain, err
} | [
"func",
"(",
"c",
"Client",
")",
"Del",
"(",
"id",
"string",
",",
"params",
"*",
"stripe",
".",
"ApplePayDomainParams",
")",
"(",
"*",
"stripe",
".",
"ApplePayDomain",
",",
"error",
")",
"{",
"path",
":=",
"stripe",
".",
"FormatURLPath",
"(",
"\"",
"\"... | // Del removes an Apple Pay domain. | [
"Del",
"removes",
"an",
"Apple",
"Pay",
"domain",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/applepaydomain/client.go#L48-L53 |
26,401 | stripe/stripe-go | log.go | Warnf | func (l *LeveledLogger) Warnf(format string, v ...interface{}) {
if l.Level >= LevelWarn {
fmt.Fprintf(l.stderr(), "[WARN] "+format+"\n", v...)
}
} | go | func (l *LeveledLogger) Warnf(format string, v ...interface{}) {
if l.Level >= LevelWarn {
fmt.Fprintf(l.stderr(), "[WARN] "+format+"\n", v...)
}
} | [
"func",
"(",
"l",
"*",
"LeveledLogger",
")",
"Warnf",
"(",
"format",
"string",
",",
"v",
"...",
"interface",
"{",
"}",
")",
"{",
"if",
"l",
".",
"Level",
">=",
"LevelWarn",
"{",
"fmt",
".",
"Fprintf",
"(",
"l",
".",
"stderr",
"(",
")",
",",
"\"",... | // Warnf logs a warning message using Printf conventions. | [
"Warnf",
"logs",
"a",
"warning",
"message",
"using",
"Printf",
"conventions",
"."
] | aa901d66c475fdd6d86581c5e1f2f85ec1f074f6 | https://github.com/stripe/stripe-go/blob/aa901d66c475fdd6d86581c5e1f2f85ec1f074f6/log.go#L123-L127 |
26,402 | faiface/beep | effects/pan.go | Stream | func (p *Pan) Stream(samples [][2]float64) (n int, ok bool) {
n, ok = p.Streamer.Stream(samples)
switch {
case p.Pan < 0:
for i := range samples[:n] {
r := samples[i][1]
samples[i][0] += -p.Pan * r
samples[i][1] -= -p.Pan * r
}
case p.Pan > 0:
for i := range samples[:n] {
l := samples[i][0]
sam... | go | func (p *Pan) Stream(samples [][2]float64) (n int, ok bool) {
n, ok = p.Streamer.Stream(samples)
switch {
case p.Pan < 0:
for i := range samples[:n] {
r := samples[i][1]
samples[i][0] += -p.Pan * r
samples[i][1] -= -p.Pan * r
}
case p.Pan > 0:
for i := range samples[:n] {
l := samples[i][0]
sam... | [
"func",
"(",
"p",
"*",
"Pan",
")",
"Stream",
"(",
"samples",
"[",
"]",
"[",
"2",
"]",
"float64",
")",
"(",
"n",
"int",
",",
"ok",
"bool",
")",
"{",
"n",
",",
"ok",
"=",
"p",
".",
"Streamer",
".",
"Stream",
"(",
"samples",
")",
"\n",
"switch",... | // Stream streams the wrapped Streamer balanced by Pan. | [
"Stream",
"streams",
"the",
"wrapped",
"Streamer",
"balanced",
"by",
"Pan",
"."
] | e59a7440241ac37c8debc0c36d69a6a489850a1f | https://github.com/faiface/beep/blob/e59a7440241ac37c8debc0c36d69a6a489850a1f/effects/pan.go#L14-L31 |
26,403 | faiface/beep | resample.go | ResampleRatio | func ResampleRatio(quality int, ratio float64, s Streamer) *Resampler {
if quality < 1 || 64 < quality {
panic(fmt.Errorf("resample: invalid quality: %d", quality))
}
return &Resampler{
s: s,
ratio: ratio,
first: true,
buf1: make([][2]float64, 512),
buf2: make([][2]float64, 512),
pts: make([]po... | go | func ResampleRatio(quality int, ratio float64, s Streamer) *Resampler {
if quality < 1 || 64 < quality {
panic(fmt.Errorf("resample: invalid quality: %d", quality))
}
return &Resampler{
s: s,
ratio: ratio,
first: true,
buf1: make([][2]float64, 512),
buf2: make([][2]float64, 512),
pts: make([]po... | [
"func",
"ResampleRatio",
"(",
"quality",
"int",
",",
"ratio",
"float64",
",",
"s",
"Streamer",
")",
"*",
"Resampler",
"{",
"if",
"quality",
"<",
"1",
"||",
"64",
"<",
"quality",
"{",
"panic",
"(",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"quality"... | // ResampleRatio is same as Resample, except it takes the ratio of the old and the new sample rate,
// specifically, the old sample rate divided by the new sample rate. Aside from correcting the
// sample rate, this can be used to change the speed of the audio. For example, resampling at the
// ratio of 2 and playing a... | [
"ResampleRatio",
"is",
"same",
"as",
"Resample",
"except",
"it",
"takes",
"the",
"ratio",
"of",
"the",
"old",
"and",
"the",
"new",
"sample",
"rate",
"specifically",
"the",
"old",
"sample",
"rate",
"divided",
"by",
"the",
"new",
"sample",
"rate",
".",
"Asid... | e59a7440241ac37c8debc0c36d69a6a489850a1f | https://github.com/faiface/beep/blob/e59a7440241ac37c8debc0c36d69a6a489850a1f/resample.go#L43-L57 |
26,404 | faiface/beep | resample.go | Stream | func (r *Resampler) Stream(samples [][2]float64) (n int, ok bool) {
// if it's the first time, we need to fill buf2 with initial data, buf1 remains zeroed
if r.first {
sn, _ := r.s.Stream(r.buf2)
r.buf2 = r.buf2[:sn]
r.first = false
}
// we start resampling, sample by sample
for len(samples) > 0 {
again:
... | go | func (r *Resampler) Stream(samples [][2]float64) (n int, ok bool) {
// if it's the first time, we need to fill buf2 with initial data, buf1 remains zeroed
if r.first {
sn, _ := r.s.Stream(r.buf2)
r.buf2 = r.buf2[:sn]
r.first = false
}
// we start resampling, sample by sample
for len(samples) > 0 {
again:
... | [
"func",
"(",
"r",
"*",
"Resampler",
")",
"Stream",
"(",
"samples",
"[",
"]",
"[",
"2",
"]",
"float64",
")",
"(",
"n",
"int",
",",
"ok",
"bool",
")",
"{",
"// if it's the first time, we need to fill buf2 with initial data, buf1 remains zeroed",
"if",
"r",
".",
... | // Stream streams the original audio resampled according to the current ratio. | [
"Stream",
"streams",
"the",
"original",
"audio",
"resampled",
"according",
"to",
"the",
"current",
"ratio",
"."
] | e59a7440241ac37c8debc0c36d69a6a489850a1f | https://github.com/faiface/beep/blob/e59a7440241ac37c8debc0c36d69a6a489850a1f/resample.go#L73-L137 |
26,405 | faiface/beep | resample.go | SetRatio | func (r *Resampler) SetRatio(ratio float64) {
r.pos = int(float64(r.pos) * r.ratio / ratio)
r.ratio = ratio
} | go | func (r *Resampler) SetRatio(ratio float64) {
r.pos = int(float64(r.pos) * r.ratio / ratio)
r.ratio = ratio
} | [
"func",
"(",
"r",
"*",
"Resampler",
")",
"SetRatio",
"(",
"ratio",
"float64",
")",
"{",
"r",
".",
"pos",
"=",
"int",
"(",
"float64",
"(",
"r",
".",
"pos",
")",
"*",
"r",
".",
"ratio",
"/",
"ratio",
")",
"\n",
"r",
".",
"ratio",
"=",
"ratio",
... | // SetRatio sets the resampling ratio. This does not cause any glitches in the stream. | [
"SetRatio",
"sets",
"the",
"resampling",
"ratio",
".",
"This",
"does",
"not",
"cause",
"any",
"glitches",
"in",
"the",
"stream",
"."
] | e59a7440241ac37c8debc0c36d69a6a489850a1f | https://github.com/faiface/beep/blob/e59a7440241ac37c8debc0c36d69a6a489850a1f/resample.go#L150-L153 |
26,406 | faiface/beep | ctrl.go | Stream | func (c *Ctrl) Stream(samples [][2]float64) (n int, ok bool) {
if c.Streamer == nil {
return 0, false
}
if c.Paused {
for i := range samples {
samples[i] = [2]float64{}
}
return len(samples), true
}
return c.Streamer.Stream(samples)
} | go | func (c *Ctrl) Stream(samples [][2]float64) (n int, ok bool) {
if c.Streamer == nil {
return 0, false
}
if c.Paused {
for i := range samples {
samples[i] = [2]float64{}
}
return len(samples), true
}
return c.Streamer.Stream(samples)
} | [
"func",
"(",
"c",
"*",
"Ctrl",
")",
"Stream",
"(",
"samples",
"[",
"]",
"[",
"2",
"]",
"float64",
")",
"(",
"n",
"int",
",",
"ok",
"bool",
")",
"{",
"if",
"c",
".",
"Streamer",
"==",
"nil",
"{",
"return",
"0",
",",
"false",
"\n",
"}",
"\n",
... | // Stream streams the wrapped Streamer, if not nil. If the Streamer is nil, Ctrl acts as drained.
// When paused, Ctrl streams silence. | [
"Stream",
"streams",
"the",
"wrapped",
"Streamer",
"if",
"not",
"nil",
".",
"If",
"the",
"Streamer",
"is",
"nil",
"Ctrl",
"acts",
"as",
"drained",
".",
"When",
"paused",
"Ctrl",
"streams",
"silence",
"."
] | e59a7440241ac37c8debc0c36d69a6a489850a1f | https://github.com/faiface/beep/blob/e59a7440241ac37c8debc0c36d69a6a489850a1f/ctrl.go#L33-L44 |
26,407 | faiface/beep | ctrl.go | Err | func (c *Ctrl) Err() error {
if c.Streamer == nil {
return nil
}
return c.Streamer.Err()
} | go | func (c *Ctrl) Err() error {
if c.Streamer == nil {
return nil
}
return c.Streamer.Err()
} | [
"func",
"(",
"c",
"*",
"Ctrl",
")",
"Err",
"(",
")",
"error",
"{",
"if",
"c",
".",
"Streamer",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"c",
".",
"Streamer",
".",
"Err",
"(",
")",
"\n",
"}"
] | // Err returns the error of the wrapped Streamer, if not nil. | [
"Err",
"returns",
"the",
"error",
"of",
"the",
"wrapped",
"Streamer",
"if",
"not",
"nil",
"."
] | e59a7440241ac37c8debc0c36d69a6a489850a1f | https://github.com/faiface/beep/blob/e59a7440241ac37c8debc0c36d69a6a489850a1f/ctrl.go#L47-L52 |
26,408 | faiface/beep | buffer.go | D | func (sr SampleRate) D(n int) time.Duration {
return time.Second * time.Duration(n) / time.Duration(sr)
} | go | func (sr SampleRate) D(n int) time.Duration {
return time.Second * time.Duration(n) / time.Duration(sr)
} | [
"func",
"(",
"sr",
"SampleRate",
")",
"D",
"(",
"n",
"int",
")",
"time",
".",
"Duration",
"{",
"return",
"time",
".",
"Second",
"*",
"time",
".",
"Duration",
"(",
"n",
")",
"/",
"time",
".",
"Duration",
"(",
"sr",
")",
"\n",
"}"
] | // D returns the duration of n samples. | [
"D",
"returns",
"the",
"duration",
"of",
"n",
"samples",
"."
] | e59a7440241ac37c8debc0c36d69a6a489850a1f | https://github.com/faiface/beep/blob/e59a7440241ac37c8debc0c36d69a6a489850a1f/buffer.go#L13-L15 |
26,409 | faiface/beep | buffer.go | N | func (sr SampleRate) N(d time.Duration) int {
return int(d * time.Duration(sr) / time.Second)
} | go | func (sr SampleRate) N(d time.Duration) int {
return int(d * time.Duration(sr) / time.Second)
} | [
"func",
"(",
"sr",
"SampleRate",
")",
"N",
"(",
"d",
"time",
".",
"Duration",
")",
"int",
"{",
"return",
"int",
"(",
"d",
"*",
"time",
".",
"Duration",
"(",
"sr",
")",
"/",
"time",
".",
"Second",
")",
"\n",
"}"
] | // N returns the number of samples that last for d duration. | [
"N",
"returns",
"the",
"number",
"of",
"samples",
"that",
"last",
"for",
"d",
"duration",
"."
] | e59a7440241ac37c8debc0c36d69a6a489850a1f | https://github.com/faiface/beep/blob/e59a7440241ac37c8debc0c36d69a6a489850a1f/buffer.go#L18-L20 |
26,410 | faiface/beep | buffer.go | NewBuffer | func NewBuffer(f Format) *Buffer {
return &Buffer{f: f, tmp: make([]byte, f.Width())}
} | go | func NewBuffer(f Format) *Buffer {
return &Buffer{f: f, tmp: make([]byte, f.Width())}
} | [
"func",
"NewBuffer",
"(",
"f",
"Format",
")",
"*",
"Buffer",
"{",
"return",
"&",
"Buffer",
"{",
"f",
":",
"f",
",",
"tmp",
":",
"make",
"(",
"[",
"]",
"byte",
",",
"f",
".",
"Width",
"(",
")",
")",
"}",
"\n",
"}"
] | // NewBuffer creates a new empty Buffer which stores samples in the provided format. | [
"NewBuffer",
"creates",
"a",
"new",
"empty",
"Buffer",
"which",
"stores",
"samples",
"in",
"the",
"provided",
"format",
"."
] | e59a7440241ac37c8debc0c36d69a6a489850a1f | https://github.com/faiface/beep/blob/e59a7440241ac37c8debc0c36d69a6a489850a1f/buffer.go#L171-L173 |
26,411 | faiface/beep | buffer.go | Len | func (b *Buffer) Len() int {
return len(b.data) / b.f.Width()
} | go | func (b *Buffer) Len() int {
return len(b.data) / b.f.Width()
} | [
"func",
"(",
"b",
"*",
"Buffer",
")",
"Len",
"(",
")",
"int",
"{",
"return",
"len",
"(",
"b",
".",
"data",
")",
"/",
"b",
".",
"f",
".",
"Width",
"(",
")",
"\n",
"}"
] | // Len returns the number of samples currently in the Buffer. | [
"Len",
"returns",
"the",
"number",
"of",
"samples",
"currently",
"in",
"the",
"Buffer",
"."
] | e59a7440241ac37c8debc0c36d69a6a489850a1f | https://github.com/faiface/beep/blob/e59a7440241ac37c8debc0c36d69a6a489850a1f/buffer.go#L181-L183 |
26,412 | faiface/beep | buffer.go | Pop | func (b *Buffer) Pop(n int) {
b.data = b.data[n:]
} | go | func (b *Buffer) Pop(n int) {
b.data = b.data[n:]
} | [
"func",
"(",
"b",
"*",
"Buffer",
")",
"Pop",
"(",
"n",
"int",
")",
"{",
"b",
".",
"data",
"=",
"b",
".",
"data",
"[",
"n",
":",
"]",
"\n",
"}"
] | // Pop removes n samples from the beginning of the Buffer.
//
// Existing Streamers are not affected. | [
"Pop",
"removes",
"n",
"samples",
"from",
"the",
"beginning",
"of",
"the",
"Buffer",
".",
"Existing",
"Streamers",
"are",
"not",
"affected",
"."
] | e59a7440241ac37c8debc0c36d69a6a489850a1f | https://github.com/faiface/beep/blob/e59a7440241ac37c8debc0c36d69a6a489850a1f/buffer.go#L188-L190 |
26,413 | faiface/beep | buffer.go | Append | func (b *Buffer) Append(s Streamer) {
var samples [512][2]float64
for {
n, ok := s.Stream(samples[:])
if !ok {
break
}
for _, sample := range samples[:n] {
b.f.EncodeSigned(b.tmp, sample)
b.data = append(b.data, b.tmp...)
}
}
} | go | func (b *Buffer) Append(s Streamer) {
var samples [512][2]float64
for {
n, ok := s.Stream(samples[:])
if !ok {
break
}
for _, sample := range samples[:n] {
b.f.EncodeSigned(b.tmp, sample)
b.data = append(b.data, b.tmp...)
}
}
} | [
"func",
"(",
"b",
"*",
"Buffer",
")",
"Append",
"(",
"s",
"Streamer",
")",
"{",
"var",
"samples",
"[",
"512",
"]",
"[",
"2",
"]",
"float64",
"\n",
"for",
"{",
"n",
",",
"ok",
":=",
"s",
".",
"Stream",
"(",
"samples",
"[",
":",
"]",
")",
"\n",... | // Append adds all audio data from the given Streamer to the end of the Buffer.
//
// The Streamer will be drained when this method finishes. | [
"Append",
"adds",
"all",
"audio",
"data",
"from",
"the",
"given",
"Streamer",
"to",
"the",
"end",
"of",
"the",
"Buffer",
".",
"The",
"Streamer",
"will",
"be",
"drained",
"when",
"this",
"method",
"finishes",
"."
] | e59a7440241ac37c8debc0c36d69a6a489850a1f | https://github.com/faiface/beep/blob/e59a7440241ac37c8debc0c36d69a6a489850a1f/buffer.go#L195-L207 |
26,414 | faiface/beep | mp3/decode.go | Decode | func Decode(rc io.ReadCloser) (s beep.StreamSeekCloser, format beep.Format, err error) {
defer func() {
if err != nil {
err = errors.Wrap(err, "mp3")
}
}()
d, err := gomp3.NewDecoder(rc)
if err != nil {
return nil, beep.Format{}, err
}
format = beep.Format{
SampleRate: beep.SampleRate(d.SampleRate()),... | go | func Decode(rc io.ReadCloser) (s beep.StreamSeekCloser, format beep.Format, err error) {
defer func() {
if err != nil {
err = errors.Wrap(err, "mp3")
}
}()
d, err := gomp3.NewDecoder(rc)
if err != nil {
return nil, beep.Format{}, err
}
format = beep.Format{
SampleRate: beep.SampleRate(d.SampleRate()),... | [
"func",
"Decode",
"(",
"rc",
"io",
".",
"ReadCloser",
")",
"(",
"s",
"beep",
".",
"StreamSeekCloser",
",",
"format",
"beep",
".",
"Format",
",",
"err",
"error",
")",
"{",
"defer",
"func",
"(",
")",
"{",
"if",
"err",
"!=",
"nil",
"{",
"err",
"=",
... | // Decode takes a ReadCloser containing audio data in MP3 format and returns a StreamSeekCloser,
// which streams that audio. The Seek method will panic if rc is not io.Seeker.
//
// Do not close the supplied ReadSeekCloser, instead, use the Close method of the returned
// StreamSeekCloser when you want to release the ... | [
"Decode",
"takes",
"a",
"ReadCloser",
"containing",
"audio",
"data",
"in",
"MP3",
"format",
"and",
"returns",
"a",
"StreamSeekCloser",
"which",
"streams",
"that",
"audio",
".",
"The",
"Seek",
"method",
"will",
"panic",
"if",
"rc",
"is",
"not",
"io",
".",
"... | e59a7440241ac37c8debc0c36d69a6a489850a1f | https://github.com/faiface/beep/blob/e59a7440241ac37c8debc0c36d69a6a489850a1f/mp3/decode.go#L24-L40 |
26,415 | faiface/beep | effects/gain.go | Stream | func (g *Gain) Stream(samples [][2]float64) (n int, ok bool) {
n, ok = g.Streamer.Stream(samples)
for i := range samples[:n] {
samples[i][0] *= 1 + g.Gain
samples[i][1] *= 1 + g.Gain
}
return n, ok
} | go | func (g *Gain) Stream(samples [][2]float64) (n int, ok bool) {
n, ok = g.Streamer.Stream(samples)
for i := range samples[:n] {
samples[i][0] *= 1 + g.Gain
samples[i][1] *= 1 + g.Gain
}
return n, ok
} | [
"func",
"(",
"g",
"*",
"Gain",
")",
"Stream",
"(",
"samples",
"[",
"]",
"[",
"2",
"]",
"float64",
")",
"(",
"n",
"int",
",",
"ok",
"bool",
")",
"{",
"n",
",",
"ok",
"=",
"g",
".",
"Streamer",
".",
"Stream",
"(",
"samples",
")",
"\n",
"for",
... | // Stream streams the wrapped Streamer amplified by Gain. | [
"Stream",
"streams",
"the",
"wrapped",
"Streamer",
"amplified",
"by",
"Gain",
"."
] | e59a7440241ac37c8debc0c36d69a6a489850a1f | https://github.com/faiface/beep/blob/e59a7440241ac37c8debc0c36d69a6a489850a1f/effects/gain.go#L16-L23 |
26,416 | faiface/beep | streamers.go | Silence | func Silence(num int) Streamer {
return StreamerFunc(func(samples [][2]float64) (n int, ok bool) {
if num == 0 {
return 0, false
}
if 0 < num && num < len(samples) {
samples = samples[:num]
}
for i := range samples {
samples[i] = [2]float64{}
}
if num > 0 {
num -= len(samples)
}
return le... | go | func Silence(num int) Streamer {
return StreamerFunc(func(samples [][2]float64) (n int, ok bool) {
if num == 0 {
return 0, false
}
if 0 < num && num < len(samples) {
samples = samples[:num]
}
for i := range samples {
samples[i] = [2]float64{}
}
if num > 0 {
num -= len(samples)
}
return le... | [
"func",
"Silence",
"(",
"num",
"int",
")",
"Streamer",
"{",
"return",
"StreamerFunc",
"(",
"func",
"(",
"samples",
"[",
"]",
"[",
"2",
"]",
"float64",
")",
"(",
"n",
"int",
",",
"ok",
"bool",
")",
"{",
"if",
"num",
"==",
"0",
"{",
"return",
"0",
... | // Silence returns a Streamer which streams num samples of silence. If num is negative, silence is
// streamed forever. | [
"Silence",
"returns",
"a",
"Streamer",
"which",
"streams",
"num",
"samples",
"of",
"silence",
".",
"If",
"num",
"is",
"negative",
"silence",
"is",
"streamed",
"forever",
"."
] | e59a7440241ac37c8debc0c36d69a6a489850a1f | https://github.com/faiface/beep/blob/e59a7440241ac37c8debc0c36d69a6a489850a1f/streamers.go#L5-L21 |
26,417 | faiface/beep | streamers.go | Callback | func Callback(f func()) Streamer {
return StreamerFunc(func(samples [][2]float64) (n int, ok bool) {
if f != nil {
f()
f = nil
}
return 0, false
})
} | go | func Callback(f func()) Streamer {
return StreamerFunc(func(samples [][2]float64) (n int, ok bool) {
if f != nil {
f()
f = nil
}
return 0, false
})
} | [
"func",
"Callback",
"(",
"f",
"func",
"(",
")",
")",
"Streamer",
"{",
"return",
"StreamerFunc",
"(",
"func",
"(",
"samples",
"[",
"]",
"[",
"2",
"]",
"float64",
")",
"(",
"n",
"int",
",",
"ok",
"bool",
")",
"{",
"if",
"f",
"!=",
"nil",
"{",
"f"... | // Callback returns a Streamer, which does not stream any samples, but instead calls f the first
// time its Stream method is called. | [
"Callback",
"returns",
"a",
"Streamer",
"which",
"does",
"not",
"stream",
"any",
"samples",
"but",
"instead",
"calls",
"f",
"the",
"first",
"time",
"its",
"Stream",
"method",
"is",
"called",
"."
] | e59a7440241ac37c8debc0c36d69a6a489850a1f | https://github.com/faiface/beep/blob/e59a7440241ac37c8debc0c36d69a6a489850a1f/streamers.go#L25-L33 |
26,418 | faiface/beep | streamers.go | Iterate | func Iterate(g func() Streamer) Streamer {
var (
s Streamer
first = true
)
return StreamerFunc(func(samples [][2]float64) (n int, ok bool) {
if first {
s = g()
first = false
}
if s == nil {
return 0, false
}
for len(samples) > 0 {
if s == nil {
break
}
sn, sok := s.Stream(samp... | go | func Iterate(g func() Streamer) Streamer {
var (
s Streamer
first = true
)
return StreamerFunc(func(samples [][2]float64) (n int, ok bool) {
if first {
s = g()
first = false
}
if s == nil {
return 0, false
}
for len(samples) > 0 {
if s == nil {
break
}
sn, sok := s.Stream(samp... | [
"func",
"Iterate",
"(",
"g",
"func",
"(",
")",
"Streamer",
")",
"Streamer",
"{",
"var",
"(",
"s",
"Streamer",
"\n",
"first",
"=",
"true",
"\n",
")",
"\n",
"return",
"StreamerFunc",
"(",
"func",
"(",
"samples",
"[",
"]",
"[",
"2",
"]",
"float64",
")... | // Iterate returns a Streamer which successively streams Streamers obtains by calling the provided g
// function. The streaming stops when g returns nil.
//
// Iterate does not propagate errors from the generated Streamers. | [
"Iterate",
"returns",
"a",
"Streamer",
"which",
"successively",
"streams",
"Streamers",
"obtains",
"by",
"calling",
"the",
"provided",
"g",
"function",
".",
"The",
"streaming",
"stops",
"when",
"g",
"returns",
"nil",
".",
"Iterate",
"does",
"not",
"propagate",
... | e59a7440241ac37c8debc0c36d69a6a489850a1f | https://github.com/faiface/beep/blob/e59a7440241ac37c8debc0c36d69a6a489850a1f/streamers.go#L39-L65 |
26,419 | faiface/beep | flac/decode.go | Decode | func Decode(rc io.ReadCloser) (s beep.StreamSeekCloser, format beep.Format, err error) {
d := decoder{rc: rc}
defer func() { // hacky way to always close rc if an error occurred
if err != nil {
d.rc.Close()
}
}()
d.stream, err = flac.New(rc)
if err != nil {
return nil, beep.Format{}, errors.Wrap(err, "fla... | go | func Decode(rc io.ReadCloser) (s beep.StreamSeekCloser, format beep.Format, err error) {
d := decoder{rc: rc}
defer func() { // hacky way to always close rc if an error occurred
if err != nil {
d.rc.Close()
}
}()
d.stream, err = flac.New(rc)
if err != nil {
return nil, beep.Format{}, errors.Wrap(err, "fla... | [
"func",
"Decode",
"(",
"rc",
"io",
".",
"ReadCloser",
")",
"(",
"s",
"beep",
".",
"StreamSeekCloser",
",",
"format",
"beep",
".",
"Format",
",",
"err",
"error",
")",
"{",
"d",
":=",
"decoder",
"{",
"rc",
":",
"rc",
"}",
"\n",
"defer",
"func",
"(",
... | // Decode takes a ReadCloser containing audio data in FLAC format and returns a StreamSeekCloser,
// which streams that audio. The Seek method will panic if rc is not io.Seeker.
//
// Do not close the supplied ReadSeekCloser, instead, use the Close method of the returned
// StreamSeekCloser when you want to release the... | [
"Decode",
"takes",
"a",
"ReadCloser",
"containing",
"audio",
"data",
"in",
"FLAC",
"format",
"and",
"returns",
"a",
"StreamSeekCloser",
"which",
"streams",
"that",
"audio",
".",
"The",
"Seek",
"method",
"will",
"panic",
"if",
"rc",
"is",
"not",
"io",
".",
... | e59a7440241ac37c8debc0c36d69a6a489850a1f | https://github.com/faiface/beep/blob/e59a7440241ac37c8debc0c36d69a6a489850a1f/flac/decode.go#L17-L34 |
26,420 | faiface/beep | mixer.go | Add | func (m *Mixer) Add(s ...Streamer) {
m.streamers = append(m.streamers, s...)
} | go | func (m *Mixer) Add(s ...Streamer) {
m.streamers = append(m.streamers, s...)
} | [
"func",
"(",
"m",
"*",
"Mixer",
")",
"Add",
"(",
"s",
"...",
"Streamer",
")",
"{",
"m",
".",
"streamers",
"=",
"append",
"(",
"m",
".",
"streamers",
",",
"s",
"...",
")",
"\n",
"}"
] | // Add adds Streamers to the Mixer. | [
"Add",
"adds",
"Streamers",
"to",
"the",
"Mixer",
"."
] | e59a7440241ac37c8debc0c36d69a6a489850a1f | https://github.com/faiface/beep/blob/e59a7440241ac37c8debc0c36d69a6a489850a1f/mixer.go#L15-L17 |
26,421 | faiface/beep | interface.go | Stream | func (sf StreamerFunc) Stream(samples [][2]float64) (n int, ok bool) {
return sf(samples)
} | go | func (sf StreamerFunc) Stream(samples [][2]float64) (n int, ok bool) {
return sf(samples)
} | [
"func",
"(",
"sf",
"StreamerFunc",
")",
"Stream",
"(",
"samples",
"[",
"]",
"[",
"2",
"]",
"float64",
")",
"(",
"n",
"int",
",",
"ok",
"bool",
")",
"{",
"return",
"sf",
"(",
"samples",
")",
"\n",
"}"
] | // Stream calls the wrapped streaming function. | [
"Stream",
"calls",
"the",
"wrapped",
"streaming",
"function",
"."
] | e59a7440241ac37c8debc0c36d69a6a489850a1f | https://github.com/faiface/beep/blob/e59a7440241ac37c8debc0c36d69a6a489850a1f/interface.go#L99-L101 |
26,422 | faiface/beep | speaker/speaker.go | Init | func Init(sampleRate beep.SampleRate, bufferSize int) error {
mu.Lock()
defer mu.Unlock()
if player != nil {
done <- struct{}{}
player.Close()
context.Close()
}
mixer = beep.Mixer{}
numBytes := bufferSize * 4
samples = make([][2]float64, bufferSize)
buf = make([]byte, numBytes)
var err error
context... | go | func Init(sampleRate beep.SampleRate, bufferSize int) error {
mu.Lock()
defer mu.Unlock()
if player != nil {
done <- struct{}{}
player.Close()
context.Close()
}
mixer = beep.Mixer{}
numBytes := bufferSize * 4
samples = make([][2]float64, bufferSize)
buf = make([]byte, numBytes)
var err error
context... | [
"func",
"Init",
"(",
"sampleRate",
"beep",
".",
"SampleRate",
",",
"bufferSize",
"int",
")",
"error",
"{",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"player",
"!=",
"nil",
"{",
"done",
"<-",
"struct",
... | // Init initializes audio playback through speaker. Must be called before using this package.
//
// The bufferSize argument specifies the number of samples of the speaker's buffer. Bigger
// bufferSize means lower CPU usage and more reliable playback. Lower bufferSize means better
// responsiveness and less delay. | [
"Init",
"initializes",
"audio",
"playback",
"through",
"speaker",
".",
"Must",
"be",
"called",
"before",
"using",
"this",
"package",
".",
"The",
"bufferSize",
"argument",
"specifies",
"the",
"number",
"of",
"samples",
"of",
"the",
"speaker",
"s",
"buffer",
"."... | e59a7440241ac37c8debc0c36d69a6a489850a1f | https://github.com/faiface/beep/blob/e59a7440241ac37c8debc0c36d69a6a489850a1f/speaker/speaker.go#L27-L64 |
26,423 | faiface/beep | speaker/speaker.go | Play | func Play(s ...beep.Streamer) {
mu.Lock()
mixer.Add(s...)
mu.Unlock()
} | go | func Play(s ...beep.Streamer) {
mu.Lock()
mixer.Add(s...)
mu.Unlock()
} | [
"func",
"Play",
"(",
"s",
"...",
"beep",
".",
"Streamer",
")",
"{",
"mu",
".",
"Lock",
"(",
")",
"\n",
"mixer",
".",
"Add",
"(",
"s",
"...",
")",
"\n",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"}"
] | // Play starts playing all provided Streamers through the speaker. | [
"Play",
"starts",
"playing",
"all",
"provided",
"Streamers",
"through",
"the",
"speaker",
"."
] | e59a7440241ac37c8debc0c36d69a6a489850a1f | https://github.com/faiface/beep/blob/e59a7440241ac37c8debc0c36d69a6a489850a1f/speaker/speaker.go#L80-L84 |
26,424 | faiface/beep | speaker/speaker.go | update | func update() {
mu.Lock()
mixer.Stream(samples)
mu.Unlock()
for i := range samples {
for c := range samples[i] {
val := samples[i][c]
if val < -1 {
val = -1
}
if val > +1 {
val = +1
}
valInt16 := int16(val * (1<<15 - 1))
low := byte(valInt16)
high := byte(valInt16 >> 8)
buf[i*4... | go | func update() {
mu.Lock()
mixer.Stream(samples)
mu.Unlock()
for i := range samples {
for c := range samples[i] {
val := samples[i][c]
if val < -1 {
val = -1
}
if val > +1 {
val = +1
}
valInt16 := int16(val * (1<<15 - 1))
low := byte(valInt16)
high := byte(valInt16 >> 8)
buf[i*4... | [
"func",
"update",
"(",
")",
"{",
"mu",
".",
"Lock",
"(",
")",
"\n",
"mixer",
".",
"Stream",
"(",
"samples",
")",
"\n",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"for",
"i",
":=",
"range",
"samples",
"{",
"for",
"c",
":=",
"range",
"samples",
"[",
... | // update pulls new data from the playing Streamers and sends it to the speaker. Blocks until the
// data is sent and started playing. | [
"update",
"pulls",
"new",
"data",
"from",
"the",
"playing",
"Streamers",
"and",
"sends",
"it",
"to",
"the",
"speaker",
".",
"Blocks",
"until",
"the",
"data",
"is",
"sent",
"and",
"started",
"playing",
"."
] | e59a7440241ac37c8debc0c36d69a6a489850a1f | https://github.com/faiface/beep/blob/e59a7440241ac37c8debc0c36d69a6a489850a1f/speaker/speaker.go#L95-L118 |
26,425 | faiface/beep | effects/volume.go | Stream | func (v *Volume) Stream(samples [][2]float64) (n int, ok bool) {
n, ok = v.Streamer.Stream(samples)
gain := 0.0
if !v.Silent {
gain = math.Pow(v.Base, v.Volume)
}
for i := range samples[:n] {
samples[i][0] *= gain
samples[i][1] *= gain
}
return n, ok
} | go | func (v *Volume) Stream(samples [][2]float64) (n int, ok bool) {
n, ok = v.Streamer.Stream(samples)
gain := 0.0
if !v.Silent {
gain = math.Pow(v.Base, v.Volume)
}
for i := range samples[:n] {
samples[i][0] *= gain
samples[i][1] *= gain
}
return n, ok
} | [
"func",
"(",
"v",
"*",
"Volume",
")",
"Stream",
"(",
"samples",
"[",
"]",
"[",
"2",
"]",
"float64",
")",
"(",
"n",
"int",
",",
"ok",
"bool",
")",
"{",
"n",
",",
"ok",
"=",
"v",
".",
"Streamer",
".",
"Stream",
"(",
"samples",
")",
"\n",
"gain"... | // Stream streams the wrapped Streamer with volume adjusted according to Base, Volume and Silent
// fields. | [
"Stream",
"streams",
"the",
"wrapped",
"Streamer",
"with",
"volume",
"adjusted",
"according",
"to",
"Base",
"Volume",
"and",
"Silent",
"fields",
"."
] | e59a7440241ac37c8debc0c36d69a6a489850a1f | https://github.com/faiface/beep/blob/e59a7440241ac37c8debc0c36d69a6a489850a1f/effects/volume.go#L30-L41 |
26,426 | faiface/beep | compositors.go | Take | func Take(num int, s Streamer) Streamer {
return &take{
s: s,
remains: num,
}
} | go | func Take(num int, s Streamer) Streamer {
return &take{
s: s,
remains: num,
}
} | [
"func",
"Take",
"(",
"num",
"int",
",",
"s",
"Streamer",
")",
"Streamer",
"{",
"return",
"&",
"take",
"{",
"s",
":",
"s",
",",
"remains",
":",
"num",
",",
"}",
"\n",
"}"
] | // Take returns a Streamer which streams at most num samples from s.
//
// The returned Streamer propagates s's errors through Err. | [
"Take",
"returns",
"a",
"Streamer",
"which",
"streams",
"at",
"most",
"num",
"samples",
"from",
"s",
".",
"The",
"returned",
"Streamer",
"propagates",
"s",
"s",
"errors",
"through",
"Err",
"."
] | e59a7440241ac37c8debc0c36d69a6a489850a1f | https://github.com/faiface/beep/blob/e59a7440241ac37c8debc0c36d69a6a489850a1f/compositors.go#L6-L11 |
26,427 | faiface/beep | compositors.go | Loop | func Loop(count int, s StreamSeeker) Streamer {
return &loop{
s: s,
remains: count,
}
} | go | func Loop(count int, s StreamSeeker) Streamer {
return &loop{
s: s,
remains: count,
}
} | [
"func",
"Loop",
"(",
"count",
"int",
",",
"s",
"StreamSeeker",
")",
"Streamer",
"{",
"return",
"&",
"loop",
"{",
"s",
":",
"s",
",",
"remains",
":",
"count",
",",
"}",
"\n",
"}"
] | // Loop takes a StreamSeeker and plays it count times. If count is negative, s is looped infinitely.
//
// The returned Streamer propagates s's errors. | [
"Loop",
"takes",
"a",
"StreamSeeker",
"and",
"plays",
"it",
"count",
"times",
".",
"If",
"count",
"is",
"negative",
"s",
"is",
"looped",
"infinitely",
".",
"The",
"returned",
"Streamer",
"propagates",
"s",
"s",
"errors",
"."
] | e59a7440241ac37c8debc0c36d69a6a489850a1f | https://github.com/faiface/beep/blob/e59a7440241ac37c8debc0c36d69a6a489850a1f/compositors.go#L38-L43 |
26,428 | faiface/beep | compositors.go | Seq | func Seq(s ...Streamer) Streamer {
i := 0
return StreamerFunc(func(samples [][2]float64) (n int, ok bool) {
for i < len(s) && len(samples) > 0 {
sn, sok := s[i].Stream(samples)
samples = samples[sn:]
n, ok = n+sn, ok || sok
if !sok {
i++
}
}
return n, ok
})
} | go | func Seq(s ...Streamer) Streamer {
i := 0
return StreamerFunc(func(samples [][2]float64) (n int, ok bool) {
for i < len(s) && len(samples) > 0 {
sn, sok := s[i].Stream(samples)
samples = samples[sn:]
n, ok = n+sn, ok || sok
if !sok {
i++
}
}
return n, ok
})
} | [
"func",
"Seq",
"(",
"s",
"...",
"Streamer",
")",
"Streamer",
"{",
"i",
":=",
"0",
"\n",
"return",
"StreamerFunc",
"(",
"func",
"(",
"samples",
"[",
"]",
"[",
"2",
"]",
"float64",
")",
"(",
"n",
"int",
",",
"ok",
"bool",
")",
"{",
"for",
"i",
"<... | // Seq takes zero or more Streamers and returns a Streamer which streams them one by one without pauses.
//
// Seq does not propagate errors from the Streamers. | [
"Seq",
"takes",
"zero",
"or",
"more",
"Streamers",
"and",
"returns",
"a",
"Streamer",
"which",
"streams",
"them",
"one",
"by",
"one",
"without",
"pauses",
".",
"Seq",
"does",
"not",
"propagate",
"errors",
"from",
"the",
"Streamers",
"."
] | e59a7440241ac37c8debc0c36d69a6a489850a1f | https://github.com/faiface/beep/blob/e59a7440241ac37c8debc0c36d69a6a489850a1f/compositors.go#L82-L95 |
26,429 | faiface/beep | compositors.go | Mix | func Mix(s ...Streamer) Streamer {
return StreamerFunc(func(samples [][2]float64) (n int, ok bool) {
var tmp [512][2]float64
for len(samples) > 0 {
toStream := len(tmp)
if toStream > len(samples) {
toStream = len(samples)
}
// clear the samples
for i := range samples[:toStream] {
samples[i... | go | func Mix(s ...Streamer) Streamer {
return StreamerFunc(func(samples [][2]float64) (n int, ok bool) {
var tmp [512][2]float64
for len(samples) > 0 {
toStream := len(tmp)
if toStream > len(samples) {
toStream = len(samples)
}
// clear the samples
for i := range samples[:toStream] {
samples[i... | [
"func",
"Mix",
"(",
"s",
"...",
"Streamer",
")",
"Streamer",
"{",
"return",
"StreamerFunc",
"(",
"func",
"(",
"samples",
"[",
"]",
"[",
"2",
"]",
"float64",
")",
"(",
"n",
"int",
",",
"ok",
"bool",
")",
"{",
"var",
"tmp",
"[",
"512",
"]",
"[",
... | // Mix takes zero or more Streamers and returns a Streamer which streams them mixed together.
//
// Mix does not propagate errors from the Streamers. | [
"Mix",
"takes",
"zero",
"or",
"more",
"Streamers",
"and",
"returns",
"a",
"Streamer",
"which",
"streams",
"them",
"mixed",
"together",
".",
"Mix",
"does",
"not",
"propagate",
"errors",
"from",
"the",
"Streamers",
"."
] | e59a7440241ac37c8debc0c36d69a6a489850a1f | https://github.com/faiface/beep/blob/e59a7440241ac37c8debc0c36d69a6a489850a1f/compositors.go#L100-L139 |
26,430 | faiface/beep | compositors.go | Dup | func Dup(s Streamer) (t, u Streamer) {
var tBuf, uBuf [][2]float64
return &dup{&tBuf, &uBuf, s}, &dup{&uBuf, &tBuf, s}
} | go | func Dup(s Streamer) (t, u Streamer) {
var tBuf, uBuf [][2]float64
return &dup{&tBuf, &uBuf, s}, &dup{&uBuf, &tBuf, s}
} | [
"func",
"Dup",
"(",
"s",
"Streamer",
")",
"(",
"t",
",",
"u",
"Streamer",
")",
"{",
"var",
"tBuf",
",",
"uBuf",
"[",
"]",
"[",
"2",
"]",
"float64",
"\n",
"return",
"&",
"dup",
"{",
"&",
"tBuf",
",",
"&",
"uBuf",
",",
"s",
"}",
",",
"&",
"du... | // Dup returns two Streamers which both stream the same data as the original s. The two Streamers
// can't be used concurrently without synchronization. | [
"Dup",
"returns",
"two",
"Streamers",
"which",
"both",
"stream",
"the",
"same",
"data",
"as",
"the",
"original",
"s",
".",
"The",
"two",
"Streamers",
"can",
"t",
"be",
"used",
"concurrently",
"without",
"synchronization",
"."
] | e59a7440241ac37c8debc0c36d69a6a489850a1f | https://github.com/faiface/beep/blob/e59a7440241ac37c8debc0c36d69a6a489850a1f/compositors.go#L143-L146 |
26,431 | mattn/go-gtk | gdkpixbuf/gdkpixbuf.go | NewPixbufFromData | func NewPixbufFromData(pbd PixbufData) *Pixbuf {
gpixbuf := C.gdk_pixbuf_new_from_data(
C.to_gucharptr(unsafe.Pointer(&pbd.Data[0])),
C.GdkColorspace(pbd.Colorspace),
gbool(pbd.HasAlpha),
C.int(pbd.BitsPerSample),
C.int(pbd.Width),
C.int(pbd.Height),
C.int(pbd.RowStride),
nil, nil)
return &Pixbuf{
G... | go | func NewPixbufFromData(pbd PixbufData) *Pixbuf {
gpixbuf := C.gdk_pixbuf_new_from_data(
C.to_gucharptr(unsafe.Pointer(&pbd.Data[0])),
C.GdkColorspace(pbd.Colorspace),
gbool(pbd.HasAlpha),
C.int(pbd.BitsPerSample),
C.int(pbd.Width),
C.int(pbd.Height),
C.int(pbd.RowStride),
nil, nil)
return &Pixbuf{
G... | [
"func",
"NewPixbufFromData",
"(",
"pbd",
"PixbufData",
")",
"*",
"Pixbuf",
"{",
"gpixbuf",
":=",
"C",
".",
"gdk_pixbuf_new_from_data",
"(",
"C",
".",
"to_gucharptr",
"(",
"unsafe",
".",
"Pointer",
"(",
"&",
"pbd",
".",
"Data",
"[",
"0",
"]",
")",
")",
... | // NewPixbufFromData creates a Pixbuf from image data in a byte array | [
"NewPixbufFromData",
"creates",
"a",
"Pixbuf",
"from",
"image",
"data",
"in",
"a",
"byte",
"array"
] | 4deadb416788be678fb9cac22ea76dba83c946b0 | https://github.com/mattn/go-gtk/blob/4deadb416788be678fb9cac22ea76dba83c946b0/gdkpixbuf/gdkpixbuf.go#L155-L169 |
26,432 | mattn/go-gtk | gdkpixbuf/gdkpixbuf.go | Save | func (p *Pixbuf) Save(filename, savetype string, options ...string) *glib.Error {
if len(options)%2 != 0 {
argumentPanic("Save options must be even (key and value)")
}
pfilename := C.CString(filename)
defer cfree(pfilename)
psavetype := C.CString(savetype)
defer cfree(psavetype)
klen := len(options) / 2
key... | go | func (p *Pixbuf) Save(filename, savetype string, options ...string) *glib.Error {
if len(options)%2 != 0 {
argumentPanic("Save options must be even (key and value)")
}
pfilename := C.CString(filename)
defer cfree(pfilename)
psavetype := C.CString(savetype)
defer cfree(psavetype)
klen := len(options) / 2
key... | [
"func",
"(",
"p",
"*",
"Pixbuf",
")",
"Save",
"(",
"filename",
",",
"savetype",
"string",
",",
"options",
"...",
"string",
")",
"*",
"glib",
".",
"Error",
"{",
"if",
"len",
"(",
"options",
")",
"%",
"2",
"!=",
"0",
"{",
"argumentPanic",
"(",
"\"",
... | // gdk_pixbuf_get_byte_length
// gdk_pixbuf_get_option
// File saving | [
"gdk_pixbuf_get_byte_length",
"gdk_pixbuf_get_option",
"File",
"saving"
] | 4deadb416788be678fb9cac22ea76dba83c946b0 | https://github.com/mattn/go-gtk/blob/4deadb416788be678fb9cac22ea76dba83c946b0/gdkpixbuf/gdkpixbuf.go#L368-L402 |
26,433 | mattn/go-gtk | glib/glib.go | toSlice | func toSlice(ar **C.gchar) []string {
result := make([]string, 0)
for i := 0; ; i++ {
str := C.GoString(C.to_charptr(*ar))
if str == "" {
break
}
result = append(result, str)
*ar = C.next_string(*ar)
}
return result
} | go | func toSlice(ar **C.gchar) []string {
result := make([]string, 0)
for i := 0; ; i++ {
str := C.GoString(C.to_charptr(*ar))
if str == "" {
break
}
result = append(result, str)
*ar = C.next_string(*ar)
}
return result
} | [
"func",
"toSlice",
"(",
"ar",
"*",
"*",
"C",
".",
"gchar",
")",
"[",
"]",
"string",
"{",
"result",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
")",
"\n",
"for",
"i",
":=",
"0",
";",
";",
"i",
"++",
"{",
"str",
":=",
"C",
".",
"GoString... | // converts a C string array to a Go string slice | [
"converts",
"a",
"C",
"string",
"array",
"to",
"a",
"Go",
"string",
"slice"
] | 4deadb416788be678fb9cac22ea76dba83c946b0 | https://github.com/mattn/go-gtk/blob/4deadb416788be678fb9cac22ea76dba83c946b0/glib/glib.go#L73-L84 |
26,434 | mattn/go-gtk | gio/gio.go | NewGFileForPath | func NewGFileForPath(filename string) *GFile {
ptrFilename := C.CString(filename)
defer cfree(ptrFilename)
return &GFile{C.g_file_new_for_path(ptrFilename)}
} | go | func NewGFileForPath(filename string) *GFile {
ptrFilename := C.CString(filename)
defer cfree(ptrFilename)
return &GFile{C.g_file_new_for_path(ptrFilename)}
} | [
"func",
"NewGFileForPath",
"(",
"filename",
"string",
")",
"*",
"GFile",
"{",
"ptrFilename",
":=",
"C",
".",
"CString",
"(",
"filename",
")",
"\n",
"defer",
"cfree",
"(",
"ptrFilename",
")",
"\n\n",
"return",
"&",
"GFile",
"{",
"C",
".",
"g_file_new_for_pa... | // NewGFileForPath is g_file_new_for_path | [
"NewGFileForPath",
"is",
"g_file_new_for_path"
] | 4deadb416788be678fb9cac22ea76dba83c946b0 | https://github.com/mattn/go-gtk/blob/4deadb416788be678fb9cac22ea76dba83c946b0/gio/gio.go#L25-L30 |
26,435 | mattn/go-gtk | gio/gio.go | NewGFileForURI | func NewGFileForURI(uriFilename string) *GFile {
ptrFilename := C.CString(uriFilename)
defer cfree(ptrFilename)
return &GFile{C.g_file_new_for_uri(ptrFilename)}
} | go | func NewGFileForURI(uriFilename string) *GFile {
ptrFilename := C.CString(uriFilename)
defer cfree(ptrFilename)
return &GFile{C.g_file_new_for_uri(ptrFilename)}
} | [
"func",
"NewGFileForURI",
"(",
"uriFilename",
"string",
")",
"*",
"GFile",
"{",
"ptrFilename",
":=",
"C",
".",
"CString",
"(",
"uriFilename",
")",
"\n",
"defer",
"cfree",
"(",
"ptrFilename",
")",
"\n\n",
"return",
"&",
"GFile",
"{",
"C",
".",
"g_file_new_f... | // NewGFileForURI is g_file_new_for_uri | [
"NewGFileForURI",
"is",
"g_file_new_for_uri"
] | 4deadb416788be678fb9cac22ea76dba83c946b0 | https://github.com/mattn/go-gtk/blob/4deadb416788be678fb9cac22ea76dba83c946b0/gio/gio.go#L33-L38 |
26,436 | mattn/go-gtk | gio/gio.go | QueryInfo | func (f *GFile) QueryInfo(attributes string, flags GFileQueryInfoFlags) (*GFileInfo, error) {
ptr := C.CString(attributes)
defer cfree(ptr)
var gerror *C.GError
gfileinfo := C.g_file_query_info(
f.GFile,
ptr,
C.GFileQueryInfoFlags(flags),
nil, // nil is GCancellable, not yet implemented
&gerror,
)
if ... | go | func (f *GFile) QueryInfo(attributes string, flags GFileQueryInfoFlags) (*GFileInfo, error) {
ptr := C.CString(attributes)
defer cfree(ptr)
var gerror *C.GError
gfileinfo := C.g_file_query_info(
f.GFile,
ptr,
C.GFileQueryInfoFlags(flags),
nil, // nil is GCancellable, not yet implemented
&gerror,
)
if ... | [
"func",
"(",
"f",
"*",
"GFile",
")",
"QueryInfo",
"(",
"attributes",
"string",
",",
"flags",
"GFileQueryInfoFlags",
")",
"(",
"*",
"GFileInfo",
",",
"error",
")",
"{",
"ptr",
":=",
"C",
".",
"CString",
"(",
"attributes",
")",
"\n",
"defer",
"cfree",
"(... | // QueryInfo is g_file_query_info | [
"QueryInfo",
"is",
"g_file_query_info"
] | 4deadb416788be678fb9cac22ea76dba83c946b0 | https://github.com/mattn/go-gtk/blob/4deadb416788be678fb9cac22ea76dba83c946b0/gio/gio.go#L48-L66 |
26,437 | mattn/go-gtk | gio/gio.go | GetPath | func (f *GFile) GetPath() string {
return gostring(gstring(C.g_file_get_path(f.GFile)))
} | go | func (f *GFile) GetPath() string {
return gostring(gstring(C.g_file_get_path(f.GFile)))
} | [
"func",
"(",
"f",
"*",
"GFile",
")",
"GetPath",
"(",
")",
"string",
"{",
"return",
"gostring",
"(",
"gstring",
"(",
"C",
".",
"g_file_get_path",
"(",
"f",
".",
"GFile",
")",
")",
")",
"\n",
"}"
] | // GetPath is `g_file_get_path`, return real, absolute, canonical path. It might contain symlinks. | [
"GetPath",
"is",
"g_file_get_path",
"return",
"real",
"absolute",
"canonical",
"path",
".",
"It",
"might",
"contain",
"symlinks",
"."
] | 4deadb416788be678fb9cac22ea76dba83c946b0 | https://github.com/mattn/go-gtk/blob/4deadb416788be678fb9cac22ea76dba83c946b0/gio/gio.go#L69-L71 |
26,438 | mattn/go-gtk | gtk/gtk.go | stringArray2Native | func stringArray2Native(ss []string) **C.gchar {
css := C.make_strings(C.int(len(ss) + 1))
for i, s := range ss {
ptr := C.CString(s)
C.set_string(css, C.int(i), gstring(ptr))
}
C.set_string(css, C.int(len(ss)), nil)
return css
} | go | func stringArray2Native(ss []string) **C.gchar {
css := C.make_strings(C.int(len(ss) + 1))
for i, s := range ss {
ptr := C.CString(s)
C.set_string(css, C.int(i), gstring(ptr))
}
C.set_string(css, C.int(len(ss)), nil)
return css
} | [
"func",
"stringArray2Native",
"(",
"ss",
"[",
"]",
"string",
")",
"*",
"*",
"C",
".",
"gchar",
"{",
"css",
":=",
"C",
".",
"make_strings",
"(",
"C",
".",
"int",
"(",
"len",
"(",
"ss",
")",
"+",
"1",
")",
")",
"\n",
"for",
"i",
",",
"s",
":=",... | // use C.g_strfreev to free the result | [
"use",
"C",
".",
"g_strfreev",
"to",
"free",
"the",
"result"
] | 4deadb416788be678fb9cac22ea76dba83c946b0 | https://github.com/mattn/go-gtk/blob/4deadb416788be678fb9cac22ea76dba83c946b0/gtk/gtk.go#L250-L258 |
26,439 | mattn/go-gtk | gtk/gtk.go | Init | func Init(args *[]string) {
if args != nil {
argc := C.int(len(*args))
argv := C.make_strings(argc)
defer C.destroy_strings(argv)
for i, arg := range *args {
cstr := C.CString(arg)
C.set_string(argv, C.int(i), (*C.gchar)(cstr))
}
C.gtk_init((*C.int)(unsafe.Pointer(&argc)),
(***C.char)(unsafe.Poi... | go | func Init(args *[]string) {
if args != nil {
argc := C.int(len(*args))
argv := C.make_strings(argc)
defer C.destroy_strings(argv)
for i, arg := range *args {
cstr := C.CString(arg)
C.set_string(argv, C.int(i), (*C.gchar)(cstr))
}
C.gtk_init((*C.int)(unsafe.Pointer(&argc)),
(***C.char)(unsafe.Poi... | [
"func",
"Init",
"(",
"args",
"*",
"[",
"]",
"string",
")",
"{",
"if",
"args",
"!=",
"nil",
"{",
"argc",
":=",
"C",
".",
"int",
"(",
"len",
"(",
"*",
"args",
")",
")",
"\n",
"argv",
":=",
"C",
".",
"make_strings",
"(",
"argc",
")",
"\n",
"defe... | // gtk_disable_setlocale
// gtk_get_default_language
// gtk_parse_args | [
"gtk_disable_setlocale",
"gtk_get_default_language",
"gtk_parse_args"
] | 4deadb416788be678fb9cac22ea76dba83c946b0 | https://github.com/mattn/go-gtk/blob/4deadb416788be678fb9cac22ea76dba83c946b0/gtk/gtk.go#L274-L298 |
26,440 | mattn/go-gtk | gtk/gtk.go | AcceleratorParse | func AcceleratorParse(accelerator string) (uint, gdk.ModifierType) {
ptrn := C.CString(accelerator)
defer cfree(ptrn)
var key C.guint
var mods C.GdkModifierType
C.gtk_accelerator_parse(gstring(ptrn), &key, &mods)
return uint(key), gdk.ModifierType(mods)
} | go | func AcceleratorParse(accelerator string) (uint, gdk.ModifierType) {
ptrn := C.CString(accelerator)
defer cfree(ptrn)
var key C.guint
var mods C.GdkModifierType
C.gtk_accelerator_parse(gstring(ptrn), &key, &mods)
return uint(key), gdk.ModifierType(mods)
} | [
"func",
"AcceleratorParse",
"(",
"accelerator",
"string",
")",
"(",
"uint",
",",
"gdk",
".",
"ModifierType",
")",
"{",
"ptrn",
":=",
"C",
".",
"CString",
"(",
"accelerator",
")",
"\n",
"defer",
"cfree",
"(",
"ptrn",
")",
"\n\n",
"var",
"key",
"C",
".",... | // gtk_accel_group_connect
// gtk_accel_group_connect_by_path
// gtk_accel_group_disconnect
// gtk_accel_group_disconnect_key
// gtk_accel_group_query
// gtk_accel_group_activate
// gtk_accel_group_lock
// gtk_accel_group_unlock
// gtk_accel_group_from_accel_closure
// gtk_accel_groups_activate
// gtk_accel_groups_from... | [
"gtk_accel_group_connect",
"gtk_accel_group_connect_by_path",
"gtk_accel_group_disconnect",
"gtk_accel_group_disconnect_key",
"gtk_accel_group_query",
"gtk_accel_group_activate",
"gtk_accel_group_lock",
"gtk_accel_group_unlock",
"gtk_accel_group_from_accel_closure",
"gtk_accel_groups_activate",
... | 4deadb416788be678fb9cac22ea76dba83c946b0 | https://github.com/mattn/go-gtk/blob/4deadb416788be678fb9cac22ea76dba83c946b0/gtk/gtk.go#L370-L378 |
26,441 | mattn/go-gtk | gtk/gtk.go | LookupByGIcon | func (it *IconTheme) LookupByGIcon(icon *gio.GIcon, width int) *IconInfo {
return &IconInfo{C.gtk_icon_theme_lookup_by_gicon(
it.GtkIconTheme,
(*C.GIcon)(unsafe.Pointer(icon.GIcon)),
gint(width),
C.GtkIconLookupFlags(IconLookupUseBuiltin),
)}
} | go | func (it *IconTheme) LookupByGIcon(icon *gio.GIcon, width int) *IconInfo {
return &IconInfo{C.gtk_icon_theme_lookup_by_gicon(
it.GtkIconTheme,
(*C.GIcon)(unsafe.Pointer(icon.GIcon)),
gint(width),
C.GtkIconLookupFlags(IconLookupUseBuiltin),
)}
} | [
"func",
"(",
"it",
"*",
"IconTheme",
")",
"LookupByGIcon",
"(",
"icon",
"*",
"gio",
".",
"GIcon",
",",
"width",
"int",
")",
"*",
"IconInfo",
"{",
"return",
"&",
"IconInfo",
"{",
"C",
".",
"gtk_icon_theme_lookup_by_gicon",
"(",
"it",
".",
"GtkIconTheme",
... | // gtk_icon_theme_lookup_icon
// gtk_icon_theme_choose_icon
// gtk_icon_theme_lookup_by_gicon | [
"gtk_icon_theme_lookup_icon",
"gtk_icon_theme_choose_icon",
"gtk_icon_theme_lookup_by_gicon"
] | 4deadb416788be678fb9cac22ea76dba83c946b0 | https://github.com/mattn/go-gtk/blob/4deadb416788be678fb9cac22ea76dba83c946b0/gtk/gtk.go#L605-L613 |
26,442 | mattn/go-gtk | gtk/gtk.go | LoadIcon | func (ii *IconInfo) LoadIcon() (*gdkpixbuf.GdkPixbuf, error) {
var gerror *C.GError
pixbuf := C.gtk_icon_info_load_icon(ii.GtkIconInfo, &gerror)
if gerror != nil {
return nil, glib.ErrorFromNative(unsafe.Pointer(gerror))
}
return gdkpixbuf.NewGdkPixbuf(unsafe.Pointer(pixbuf)), nil
} | go | func (ii *IconInfo) LoadIcon() (*gdkpixbuf.GdkPixbuf, error) {
var gerror *C.GError
pixbuf := C.gtk_icon_info_load_icon(ii.GtkIconInfo, &gerror)
if gerror != nil {
return nil, glib.ErrorFromNative(unsafe.Pointer(gerror))
}
return gdkpixbuf.NewGdkPixbuf(unsafe.Pointer(pixbuf)), nil
} | [
"func",
"(",
"ii",
"*",
"IconInfo",
")",
"LoadIcon",
"(",
")",
"(",
"*",
"gdkpixbuf",
".",
"GdkPixbuf",
",",
"error",
")",
"{",
"var",
"gerror",
"*",
"C",
".",
"GError",
"\n",
"pixbuf",
":=",
"C",
".",
"gtk_icon_info_load_icon",
"(",
"ii",
".",
"GtkI... | // gtk_icon_info_copy
// gtk_icon_info_free
// gtk_icon_info_new_for_pixbuf
// gtk_icon_info_get_base_size
// gtk_icon_info_get_filename
// gtk_icon_info_get_builtin_pixbuf
// gtk_icon_info_load_icon | [
"gtk_icon_info_copy",
"gtk_icon_info_free",
"gtk_icon_info_new_for_pixbuf",
"gtk_icon_info_get_base_size",
"gtk_icon_info_get_filename",
"gtk_icon_info_get_builtin_pixbuf",
"gtk_icon_info_load_icon"
] | 4deadb416788be678fb9cac22ea76dba83c946b0 | https://github.com/mattn/go-gtk/blob/4deadb416788be678fb9cac22ea76dba83c946b0/gtk/gtk.go#L634-L643 |
26,443 | mattn/go-gtk | gtk/gtk.go | ToGObject | func (s *Settings) ToGObject() *glib.GObject {
return &glib.GObject{unsafe.Pointer(s.GSettings)}
} | go | func (s *Settings) ToGObject() *glib.GObject {
return &glib.GObject{unsafe.Pointer(s.GSettings)}
} | [
"func",
"(",
"s",
"*",
"Settings",
")",
"ToGObject",
"(",
")",
"*",
"glib",
".",
"GObject",
"{",
"return",
"&",
"glib",
".",
"GObject",
"{",
"unsafe",
".",
"Pointer",
"(",
"s",
".",
"GSettings",
")",
"}",
"\n",
"}"
] | // gtk_settings_install_property
// gtk_settings_install_property_parser
// gtk_rc_property_parse_color
// gtk_rc_property_parse_enum
// gtk_rc_property_parse_flags
// gtk_rc_property_parse_requisition
// gtk_rc_property_parse_border
// gtk_settings_set_property_value | [
"gtk_settings_install_property",
"gtk_settings_install_property_parser",
"gtk_rc_property_parse_color",
"gtk_rc_property_parse_enum",
"gtk_rc_property_parse_flags",
"gtk_rc_property_parse_requisition",
"gtk_rc_property_parse_border",
"gtk_settings_set_property_value"
] | 4deadb416788be678fb9cac22ea76dba83c946b0 | https://github.com/mattn/go-gtk/blob/4deadb416788be678fb9cac22ea76dba83c946b0/gtk/gtk.go#L913-L915 |
26,444 | mattn/go-gtk | gtk/gtk.go | GetHasSeparator | func (v *Dialog) GetHasSeparator() bool {
deprecated_since(2, 22, 0, "gtk_dialog_get_has_separator()")
return gobool(C.gtk_dialog_get_has_separator(DIALOG(v)))
} | go | func (v *Dialog) GetHasSeparator() bool {
deprecated_since(2, 22, 0, "gtk_dialog_get_has_separator()")
return gobool(C.gtk_dialog_get_has_separator(DIALOG(v)))
} | [
"func",
"(",
"v",
"*",
"Dialog",
")",
"GetHasSeparator",
"(",
")",
"bool",
"{",
"deprecated_since",
"(",
"2",
",",
"22",
",",
"0",
",",
"\"",
"\"",
")",
"\n",
"return",
"gobool",
"(",
"C",
".",
"gtk_dialog_get_has_separator",
"(",
"DIALOG",
"(",
"v",
... | // gtk_dialog_add_buttons
// gtk_dialog_add_action_widget
//Deprecated since 2.22. | [
"gtk_dialog_add_buttons",
"gtk_dialog_add_action_widget",
"Deprecated",
"since",
"2",
".",
"22",
"."
] | 4deadb416788be678fb9cac22ea76dba83c946b0 | https://github.com/mattn/go-gtk/blob/4deadb416788be678fb9cac22ea76dba83c946b0/gtk/gtk.go#L1257-L1260 |
26,445 | mattn/go-gtk | gtk/gtk.go | SetHasSeparator | func (v *Dialog) SetHasSeparator(f bool) {
deprecated_since(2, 22, 0, "gtk_dialog_set_has_separator()")
C.gtk_dialog_set_has_separator(DIALOG(v), gbool(f))
} | go | func (v *Dialog) SetHasSeparator(f bool) {
deprecated_since(2, 22, 0, "gtk_dialog_set_has_separator()")
C.gtk_dialog_set_has_separator(DIALOG(v), gbool(f))
} | [
"func",
"(",
"v",
"*",
"Dialog",
")",
"SetHasSeparator",
"(",
"f",
"bool",
")",
"{",
"deprecated_since",
"(",
"2",
",",
"22",
",",
"0",
",",
"\"",
"\"",
")",
"\n",
"C",
".",
"gtk_dialog_set_has_separator",
"(",
"DIALOG",
"(",
"v",
")",
",",
"gbool",
... | //Deprecated since 2.22. | [
"Deprecated",
"since",
"2",
".",
"22",
"."
] | 4deadb416788be678fb9cac22ea76dba83c946b0 | https://github.com/mattn/go-gtk/blob/4deadb416788be678fb9cac22ea76dba83c946b0/gtk/gtk.go#L1263-L1266 |
26,446 | mattn/go-gtk | gtk/gtk.go | GetVBox | func (v *Dialog) GetVBox() *VBox {
return &VBox{Box{Container{Widget{C._gtk_dialog_get_vbox(v.GWidget)}}}}
} | go | func (v *Dialog) GetVBox() *VBox {
return &VBox{Box{Container{Widget{C._gtk_dialog_get_vbox(v.GWidget)}}}}
} | [
"func",
"(",
"v",
"*",
"Dialog",
")",
"GetVBox",
"(",
")",
"*",
"VBox",
"{",
"return",
"&",
"VBox",
"{",
"Box",
"{",
"Container",
"{",
"Widget",
"{",
"C",
".",
"_gtk_dialog_get_vbox",
"(",
"v",
".",
"GWidget",
")",
"}",
"}",
"}",
"}",
"\n",
"}"
] | // gtk_alternative_dialog_button_order
// gtk_dialog_set_alternative_button_order
// gtk_dialog_set_alternative_button_order_from_array | [
"gtk_alternative_dialog_button_order",
"gtk_dialog_set_alternative_button_order",
"gtk_dialog_set_alternative_button_order_from_array"
] | 4deadb416788be678fb9cac22ea76dba83c946b0 | https://github.com/mattn/go-gtk/blob/4deadb416788be678fb9cac22ea76dba83c946b0/gtk/gtk.go#L1296-L1298 |
26,447 | mattn/go-gtk | gtk/gtk.go | SetDefault | func (v *Window) SetDefault(w *Widget) {
C.gtk_window_set_default(WINDOW(v), w.GWidget)
} | go | func (v *Window) SetDefault(w *Widget) {
C.gtk_window_set_default(WINDOW(v), w.GWidget)
} | [
"func",
"(",
"v",
"*",
"Window",
")",
"SetDefault",
"(",
"w",
"*",
"Widget",
")",
"{",
"C",
".",
"gtk_window_set_default",
"(",
"WINDOW",
"(",
"v",
")",
",",
"w",
".",
"GWidget",
")",
"\n",
"}"
] | // gtk_window_add_mnemonic
// gtk_window_remove_mnemonic
// gtk_window_mnemonic_activate
// gtk_window_activate_key
// gtk_window_propagate_key_event
// gtk_window_get_focus
// gtk_window_set_focus
// gtk_window_get_default_widget | [
"gtk_window_add_mnemonic",
"gtk_window_remove_mnemonic",
"gtk_window_mnemonic_activate",
"gtk_window_activate_key",
"gtk_window_propagate_key_event",
"gtk_window_get_focus",
"gtk_window_set_focus",
"gtk_window_get_default_widget"
] | 4deadb416788be678fb9cac22ea76dba83c946b0 | https://github.com/mattn/go-gtk/blob/4deadb416788be678fb9cac22ea76dba83c946b0/gtk/gtk.go#L1502-L1504 |
26,448 | mattn/go-gtk | gtk/gtk.go | GetDefaultSize | func (v *Window) GetDefaultSize() (width int, height int) {
var cwidth, cheight C.gint
C.gtk_window_get_default_size(WINDOW(v), &cwidth, &cheight)
return int(cwidth), int(cheight)
} | go | func (v *Window) GetDefaultSize() (width int, height int) {
var cwidth, cheight C.gint
C.gtk_window_get_default_size(WINDOW(v), &cwidth, &cheight)
return int(cwidth), int(cheight)
} | [
"func",
"(",
"v",
"*",
"Window",
")",
"GetDefaultSize",
"(",
")",
"(",
"width",
"int",
",",
"height",
"int",
")",
"{",
"var",
"cwidth",
",",
"cheight",
"C",
".",
"gint",
"\n",
"C",
".",
"gtk_window_get_default_size",
"(",
"WINDOW",
"(",
"v",
")",
","... | // gtk_window_set_focus_on_map
// gtk_window_set_startup_id
// gtk_window_set_role
// gtk_window_get_decorated
// gtk_window_get_deletable
// gtk_window_get_default_icon_list
// gtk_window_get_default_icon_name | [
"gtk_window_set_focus_on_map",
"gtk_window_set_startup_id",
"gtk_window_set_role",
"gtk_window_get_decorated",
"gtk_window_get_deletable",
"gtk_window_get_default_icon_list",
"gtk_window_get_default_icon_name"
] | 4deadb416788be678fb9cac22ea76dba83c946b0 | https://github.com/mattn/go-gtk/blob/4deadb416788be678fb9cac22ea76dba83c946b0/gtk/gtk.go#L1588-L1592 |
26,449 | mattn/go-gtk | gtk/gtk.go | SetIcon | func (v *Window) SetIcon(icon *gdkpixbuf.Pixbuf) {
C.gtk_window_set_icon(WINDOW(v), (*C.GdkPixbuf)(unsafe.Pointer(icon.GPixbuf)))
} | go | func (v *Window) SetIcon(icon *gdkpixbuf.Pixbuf) {
C.gtk_window_set_icon(WINDOW(v), (*C.GdkPixbuf)(unsafe.Pointer(icon.GPixbuf)))
} | [
"func",
"(",
"v",
"*",
"Window",
")",
"SetIcon",
"(",
"icon",
"*",
"gdkpixbuf",
".",
"Pixbuf",
")",
"{",
"C",
".",
"gtk_window_set_icon",
"(",
"WINDOW",
"(",
"v",
")",
",",
"(",
"*",
"C",
".",
"GdkPixbuf",
")",
"(",
"unsafe",
".",
"Pointer",
"(",
... | // gtk_window_set_default_icon_list
// gtk_window_set_default_icon
// gtk_window_set_default_icon_from_file
// gtk_window_set_default_icon_name | [
"gtk_window_set_default_icon_list",
"gtk_window_set_default_icon",
"gtk_window_set_default_icon_from_file",
"gtk_window_set_default_icon_name"
] | 4deadb416788be678fb9cac22ea76dba83c946b0 | https://github.com/mattn/go-gtk/blob/4deadb416788be678fb9cac22ea76dba83c946b0/gtk/gtk.go#L1667-L1669 |
26,450 | mattn/go-gtk | gtk/gtk.go | ForwardSearch | func (v *TextIter) ForwardSearch(str string, flags TextSearchFlags, start *TextIter, end *TextIter, limit *TextIter) bool {
cstr := C.CString(str)
defer cfree(cstr)
return gobool(C.gtk_text_iter_forward_search(&v.GTextIter, gstring(cstr), C.GtkTextSearchFlags(flags),
&start.GTextIter, &end.GTextIter, &limit.GTextI... | go | func (v *TextIter) ForwardSearch(str string, flags TextSearchFlags, start *TextIter, end *TextIter, limit *TextIter) bool {
cstr := C.CString(str)
defer cfree(cstr)
return gobool(C.gtk_text_iter_forward_search(&v.GTextIter, gstring(cstr), C.GtkTextSearchFlags(flags),
&start.GTextIter, &end.GTextIter, &limit.GTextI... | [
"func",
"(",
"v",
"*",
"TextIter",
")",
"ForwardSearch",
"(",
"str",
"string",
",",
"flags",
"TextSearchFlags",
",",
"start",
"*",
"TextIter",
",",
"end",
"*",
"TextIter",
",",
"limit",
"*",
"TextIter",
")",
"bool",
"{",
"cstr",
":=",
"C",
".",
"CStrin... | // gtk_text_iter_forward_line
// gtk_text_iter_backward_line
// gtk_text_iter_forward_lines
// gtk_text_iter_backward_lines
// gtk_text_iter_forward_word_ends
// gtk_text_iter_backward_word_starts
// gtk_text_iter_forward_word_end
// gtk_text_iter_backward_word_start
// gtk_text_iter_forward_cursor_position
// gtk_text... | [
"gtk_text_iter_forward_line",
"gtk_text_iter_backward_line",
"gtk_text_iter_forward_lines",
"gtk_text_iter_backward_lines",
"gtk_text_iter_forward_word_ends",
"gtk_text_iter_backward_word_starts",
"gtk_text_iter_forward_word_end",
"gtk_text_iter_backward_word_start",
"gtk_text_iter_forward_cursor_po... | 4deadb416788be678fb9cac22ea76dba83c946b0 | https://github.com/mattn/go-gtk/blob/4deadb416788be678fb9cac22ea76dba83c946b0/gtk/gtk.go#L3964-L3969 |
26,451 | mattn/go-gtk | gtk/gtk.go | Assign | func (v *TextIter) Assign(iter *TextIter) {
C._gtk_text_iter_assign(&v.GTextIter, &iter.GTextIter)
} | go | func (v *TextIter) Assign(iter *TextIter) {
C._gtk_text_iter_assign(&v.GTextIter, &iter.GTextIter)
} | [
"func",
"(",
"v",
"*",
"TextIter",
")",
"Assign",
"(",
"iter",
"*",
"TextIter",
")",
"{",
"C",
".",
"_gtk_text_iter_assign",
"(",
"&",
"v",
".",
"GTextIter",
",",
"&",
"iter",
".",
"GTextIter",
")",
"\n",
"}"
] | // gtk_text_iter_equal
// gtk_text_iter_compare
// gtk_text_iter_in_range
// gtk_text_iter_order | [
"gtk_text_iter_equal",
"gtk_text_iter_compare",
"gtk_text_iter_in_range",
"gtk_text_iter_order"
] | 4deadb416788be678fb9cac22ea76dba83c946b0 | https://github.com/mattn/go-gtk/blob/4deadb416788be678fb9cac22ea76dba83c946b0/gtk/gtk.go#L3983-L3985 |
26,452 | mattn/go-gtk | gtk/gtk.go | GetSelectionBounds | func (v *TextBuffer) GetSelectionBounds(be, en *TextIter) bool {
return gobool(C.gtk_text_buffer_get_selection_bounds(v.GTextBuffer, &be.GTextIter, &en.GTextIter))
} | go | func (v *TextBuffer) GetSelectionBounds(be, en *TextIter) bool {
return gobool(C.gtk_text_buffer_get_selection_bounds(v.GTextBuffer, &be.GTextIter, &en.GTextIter))
} | [
"func",
"(",
"v",
"*",
"TextBuffer",
")",
"GetSelectionBounds",
"(",
"be",
",",
"en",
"*",
"TextIter",
")",
"bool",
"{",
"return",
"gobool",
"(",
"C",
".",
"gtk_text_buffer_get_selection_bounds",
"(",
"v",
".",
"GTextBuffer",
",",
"&",
"be",
".",
"GTextIte... | // gtk_text_buffer_paste_clipboard
// gtk_text_buffer_copy_clipboard
// gtk_text_buffer_cut_clipboard | [
"gtk_text_buffer_paste_clipboard",
"gtk_text_buffer_copy_clipboard",
"gtk_text_buffer_cut_clipboard"
] | 4deadb416788be678fb9cac22ea76dba83c946b0 | https://github.com/mattn/go-gtk/blob/4deadb416788be678fb9cac22ea76dba83c946b0/gtk/gtk.go#L4283-L4285 |
26,453 | mattn/go-gtk | gtk/gtk.go | RemoveColumn | func (v *TreeView) RemoveColumn(c *TreeViewColumn) int {
return int(C.gtk_tree_view_remove_column(TREE_VIEW(v), c.GTreeViewColumn))
} | go | func (v *TreeView) RemoveColumn(c *TreeViewColumn) int {
return int(C.gtk_tree_view_remove_column(TREE_VIEW(v), c.GTreeViewColumn))
} | [
"func",
"(",
"v",
"*",
"TreeView",
")",
"RemoveColumn",
"(",
"c",
"*",
"TreeViewColumn",
")",
"int",
"{",
"return",
"int",
"(",
"C",
".",
"gtk_tree_view_remove_column",
"(",
"TREE_VIEW",
"(",
"v",
")",
",",
"c",
".",
"GTreeViewColumn",
")",
")",
"\n",
... | // Remove column from TreeView and return number of existing columns | [
"Remove",
"column",
"from",
"TreeView",
"and",
"return",
"number",
"of",
"existing",
"columns"
] | 4deadb416788be678fb9cac22ea76dba83c946b0 | https://github.com/mattn/go-gtk/blob/4deadb416788be678fb9cac22ea76dba83c946b0/gtk/gtk.go#L5217-L5219 |
26,454 | mattn/go-gtk | gtk/gtk.go | GetActiveText | func (v *ComboBox) GetActiveText() string {
deprecated_since(2, 24, 0, "gtk_combo_box_get_active_text()")
return gostring(C.gtk_combo_box_get_active_text(COMBO_BOX(v)))
} | go | func (v *ComboBox) GetActiveText() string {
deprecated_since(2, 24, 0, "gtk_combo_box_get_active_text()")
return gostring(C.gtk_combo_box_get_active_text(COMBO_BOX(v)))
} | [
"func",
"(",
"v",
"*",
"ComboBox",
")",
"GetActiveText",
"(",
")",
"string",
"{",
"deprecated_since",
"(",
"2",
",",
"24",
",",
"0",
",",
"\"",
"\"",
")",
"\n",
"return",
"gostring",
"(",
"C",
".",
"gtk_combo_box_get_active_text",
"(",
"COMBO_BOX",
"(",
... | //Deprecated since 2.24. Use GtkComboBoxText or, if combo box contains an entry,
// get text directly from GtkEntry. | [
"Deprecated",
"since",
"2",
".",
"24",
".",
"Use",
"GtkComboBoxText",
"or",
"if",
"combo",
"box",
"contains",
"an",
"entry",
"get",
"text",
"directly",
"from",
"GtkEntry",
"."
] | 4deadb416788be678fb9cac22ea76dba83c946b0 | https://github.com/mattn/go-gtk/blob/4deadb416788be678fb9cac22ea76dba83c946b0/gtk/gtk.go#L6156-L6159 |
26,455 | mattn/go-gtk | gtk/gtk.go | SetAddTearoffs | func (v *ComboBox) SetAddTearoffs(add_tearoffs bool) {
C.gtk_combo_box_set_add_tearoffs(COMBO_BOX(v), gbool(add_tearoffs))
} | go | func (v *ComboBox) SetAddTearoffs(add_tearoffs bool) {
C.gtk_combo_box_set_add_tearoffs(COMBO_BOX(v), gbool(add_tearoffs))
} | [
"func",
"(",
"v",
"*",
"ComboBox",
")",
"SetAddTearoffs",
"(",
"add_tearoffs",
"bool",
")",
"{",
"C",
".",
"gtk_combo_box_set_add_tearoffs",
"(",
"COMBO_BOX",
"(",
"v",
")",
",",
"gbool",
"(",
"add_tearoffs",
")",
")",
"\n",
"}"
] | // gtk_combo_box_get_popup_accessible
// gtk_combo_box_get_row_separator_func
// gtk_combo_box_set_row_separator_func | [
"gtk_combo_box_get_popup_accessible",
"gtk_combo_box_get_row_separator_func",
"gtk_combo_box_set_row_separator_func"
] | 4deadb416788be678fb9cac22ea76dba83c946b0 | https://github.com/mattn/go-gtk/blob/4deadb416788be678fb9cac22ea76dba83c946b0/gtk/gtk.go#L6173-L6175 |
26,456 | mattn/go-gtk | gtk/gtk.go | SetGroup | func (v *RadioMenuItem) SetGroup(group *glib.SList) {
C.gtk_radio_menu_item_set_group(RADIO_MENU_ITEM(v), gslist(group))
} | go | func (v *RadioMenuItem) SetGroup(group *glib.SList) {
C.gtk_radio_menu_item_set_group(RADIO_MENU_ITEM(v), gslist(group))
} | [
"func",
"(",
"v",
"*",
"RadioMenuItem",
")",
"SetGroup",
"(",
"group",
"*",
"glib",
".",
"SList",
")",
"{",
"C",
".",
"gtk_radio_menu_item_set_group",
"(",
"RADIO_MENU_ITEM",
"(",
"v",
")",
",",
"gslist",
"(",
"group",
")",
")",
"\n",
"}"
] | // gtk_radio_menu_item_new_with_mnemonic
// gtk_radio_menu_item_new_from_widget
// gtk_radio_menu_item_new_with_label_from_widget
// gtk_radio_menu_item_new_with_mnemonic_from_widget
// gtk_radio_menu_item_group | [
"gtk_radio_menu_item_new_with_mnemonic",
"gtk_radio_menu_item_new_from_widget",
"gtk_radio_menu_item_new_with_label_from_widget",
"gtk_radio_menu_item_new_with_mnemonic_from_widget",
"gtk_radio_menu_item_group"
] | 4deadb416788be678fb9cac22ea76dba83c946b0 | https://github.com/mattn/go-gtk/blob/4deadb416788be678fb9cac22ea76dba83c946b0/gtk/gtk.go#L6606-L6608 |
26,457 | mattn/go-gtk | gtk/gtk.go | SelectFilename | func (v *FileChooser) SelectFilename(filename string) bool {
ptr := C.CString(filename)
defer cfree(ptr)
return gobool(C.gtk_file_chooser_select_filename(v.GFileChooser, ptr))
} | go | func (v *FileChooser) SelectFilename(filename string) bool {
ptr := C.CString(filename)
defer cfree(ptr)
return gobool(C.gtk_file_chooser_select_filename(v.GFileChooser, ptr))
} | [
"func",
"(",
"v",
"*",
"FileChooser",
")",
"SelectFilename",
"(",
"filename",
"string",
")",
"bool",
"{",
"ptr",
":=",
"C",
".",
"CString",
"(",
"filename",
")",
"\n",
"defer",
"cfree",
"(",
"ptr",
")",
"\n",
"return",
"gobool",
"(",
"C",
".",
"gtk_f... | // GTK doc said the return value is "Not useful". | [
"GTK",
"doc",
"said",
"the",
"return",
"value",
"is",
"Not",
"useful",
"."
] | 4deadb416788be678fb9cac22ea76dba83c946b0 | https://github.com/mattn/go-gtk/blob/4deadb416788be678fb9cac22ea76dba83c946b0/gtk/gtk.go#L8113-L8117 |
26,458 | mattn/go-gtk | gtk/gtk.go | Configure | func (v *Adjustment) Configure(value, lower, upper, step_increment, page_increment, page_size float64) {
panic_if_version_older(2, 14, 0, "gtk_adjustment_configure()")
C._gtk_adjustment_configure(v.GAdjustment, gdouble(value), gdouble(lower), gdouble(upper),
gdouble(step_increment), gdouble(page_increment), gdouble... | go | func (v *Adjustment) Configure(value, lower, upper, step_increment, page_increment, page_size float64) {
panic_if_version_older(2, 14, 0, "gtk_adjustment_configure()")
C._gtk_adjustment_configure(v.GAdjustment, gdouble(value), gdouble(lower), gdouble(upper),
gdouble(step_increment), gdouble(page_increment), gdouble... | [
"func",
"(",
"v",
"*",
"Adjustment",
")",
"Configure",
"(",
"value",
",",
"lower",
",",
"upper",
",",
"step_increment",
",",
"page_increment",
",",
"page_size",
"float64",
")",
"{",
"panic_if_version_older",
"(",
"2",
",",
"14",
",",
"0",
",",
"\"",
"\""... | // gtk_adjustment_clamp_page
// gtk_adjustment_changed
// gtk_adjustment_value_changed | [
"gtk_adjustment_clamp_page",
"gtk_adjustment_changed",
"gtk_adjustment_value_changed"
] | 4deadb416788be678fb9cac22ea76dba83c946b0 | https://github.com/mattn/go-gtk/blob/4deadb416788be678fb9cac22ea76dba83c946b0/gtk/gtk.go#L9687-L9691 |
26,459 | mattn/go-gtk | gtk/gtk.go | NewArrow | func NewArrow(at ArrowType, st ShadowType) *Arrow {
return &Arrow{Widget{C.gtk_arrow_new(C.GtkArrowType(at), C.GtkShadowType(st))}}
} | go | func NewArrow(at ArrowType, st ShadowType) *Arrow {
return &Arrow{Widget{C.gtk_arrow_new(C.GtkArrowType(at), C.GtkShadowType(st))}}
} | [
"func",
"NewArrow",
"(",
"at",
"ArrowType",
",",
"st",
"ShadowType",
")",
"*",
"Arrow",
"{",
"return",
"&",
"Arrow",
"{",
"Widget",
"{",
"C",
".",
"gtk_arrow_new",
"(",
"C",
".",
"GtkArrowType",
"(",
"at",
")",
",",
"C",
".",
"GtkShadowType",
"(",
"s... | // Draw arrowhead facing in given direction with a shadow.
// Like gtk.Label it does not emit signals. | [
"Draw",
"arrowhead",
"facing",
"in",
"given",
"direction",
"with",
"a",
"shadow",
".",
"Like",
"gtk",
".",
"Label",
"it",
"does",
"not",
"emit",
"signals",
"."
] | 4deadb416788be678fb9cac22ea76dba83c946b0 | https://github.com/mattn/go-gtk/blob/4deadb416788be678fb9cac22ea76dba83c946b0/gtk/gtk.go#L9767-L9769 |
26,460 | mattn/go-gtk | gtk/gtk.go | Set | func (a *Arrow) Set(at ArrowType, st ShadowType) {
C.gtk_arrow_set(ARROW(a), C.GtkArrowType(at), C.GtkShadowType(st))
} | go | func (a *Arrow) Set(at ArrowType, st ShadowType) {
C.gtk_arrow_set(ARROW(a), C.GtkArrowType(at), C.GtkShadowType(st))
} | [
"func",
"(",
"a",
"*",
"Arrow",
")",
"Set",
"(",
"at",
"ArrowType",
",",
"st",
"ShadowType",
")",
"{",
"C",
".",
"gtk_arrow_set",
"(",
"ARROW",
"(",
"a",
")",
",",
"C",
".",
"GtkArrowType",
"(",
"at",
")",
",",
"C",
".",
"GtkShadowType",
"(",
"st... | // Change the arrows direction and shadow. | [
"Change",
"the",
"arrows",
"direction",
"and",
"shadow",
"."
] | 4deadb416788be678fb9cac22ea76dba83c946b0 | https://github.com/mattn/go-gtk/blob/4deadb416788be678fb9cac22ea76dba83c946b0/gtk/gtk.go#L9772-L9774 |
26,461 | mattn/go-gtk | gtk/gtk.go | EventBoxFromObject | func EventBoxFromObject(object *glib.GObject) *EventBox {
return &EventBox{Bin{Container{Widget{C.toGWidget(object.Object)}}}}
} | go | func EventBoxFromObject(object *glib.GObject) *EventBox {
return &EventBox{Bin{Container{Widget{C.toGWidget(object.Object)}}}}
} | [
"func",
"EventBoxFromObject",
"(",
"object",
"*",
"glib",
".",
"GObject",
")",
"*",
"EventBox",
"{",
"return",
"&",
"EventBox",
"{",
"Bin",
"{",
"Container",
"{",
"Widget",
"{",
"C",
".",
"toGWidget",
"(",
"object",
".",
"Object",
")",
"}",
"}",
"}",
... | //add by xtlx2000 | [
"add",
"by",
"xtlx2000"
] | 4deadb416788be678fb9cac22ea76dba83c946b0 | https://github.com/mattn/go-gtk/blob/4deadb416788be678fb9cac22ea76dba83c946b0/gtk/gtk.go#L9827-L9829 |
26,462 | mattn/go-gtk | gtk/gtk.go | ChildSet | func (v *Container) ChildSet(w IWidget, propName string, value interface{}) {
ptr := C.CString(propName)
defer cfree(ptr)
switch value.(type) {
case bool:
C._gtk_container_child_set_bool(CONTAINER(v), ToNative(w), gstring(ptr), gbool(value.(bool)))
case int:
C._gtk_container_child_set_int(CONTAINER(v), ToNat... | go | func (v *Container) ChildSet(w IWidget, propName string, value interface{}) {
ptr := C.CString(propName)
defer cfree(ptr)
switch value.(type) {
case bool:
C._gtk_container_child_set_bool(CONTAINER(v), ToNative(w), gstring(ptr), gbool(value.(bool)))
case int:
C._gtk_container_child_set_int(CONTAINER(v), ToNat... | [
"func",
"(",
"v",
"*",
"Container",
")",
"ChildSet",
"(",
"w",
"IWidget",
",",
"propName",
"string",
",",
"value",
"interface",
"{",
"}",
")",
"{",
"ptr",
":=",
"C",
".",
"CString",
"(",
"propName",
")",
"\n",
"defer",
"cfree",
"(",
"ptr",
")",
"\n... | // gtk_container_resize_children
// gtk_container_child_type
// gtk_container_child_get | [
"gtk_container_resize_children",
"gtk_container_child_type",
"gtk_container_child_get"
] | 4deadb416788be678fb9cac22ea76dba83c946b0 | https://github.com/mattn/go-gtk/blob/4deadb416788be678fb9cac22ea76dba83c946b0/gtk/gtk.go#L10211-L10222 |
26,463 | mattn/go-gtk | gtk/gtk.go | AddAccelerator | func (v *Widget) AddAccelerator(signal string, group *AccelGroup, key uint, mods gdk.ModifierType, flags AccelFlags) {
csignal := C.CString(signal)
defer cfree(csignal)
C.gtk_widget_add_accelerator(v.GWidget, gstring(csignal), group.GAccelGroup, guint(key),
C.GdkModifierType(mods), C.GtkAccelFlags(flags))
} | go | func (v *Widget) AddAccelerator(signal string, group *AccelGroup, key uint, mods gdk.ModifierType, flags AccelFlags) {
csignal := C.CString(signal)
defer cfree(csignal)
C.gtk_widget_add_accelerator(v.GWidget, gstring(csignal), group.GAccelGroup, guint(key),
C.GdkModifierType(mods), C.GtkAccelFlags(flags))
} | [
"func",
"(",
"v",
"*",
"Widget",
")",
"AddAccelerator",
"(",
"signal",
"string",
",",
"group",
"*",
"AccelGroup",
",",
"key",
"uint",
",",
"mods",
"gdk",
".",
"ModifierType",
",",
"flags",
"AccelFlags",
")",
"{",
"csignal",
":=",
"C",
".",
"CString",
"... | // gtk_widget_size_request
// gtk_widget_get_child_requisition
// gtk_widget_size_allocate | [
"gtk_widget_size_request",
"gtk_widget_get_child_requisition",
"gtk_widget_size_allocate"
] | 4deadb416788be678fb9cac22ea76dba83c946b0 | https://github.com/mattn/go-gtk/blob/4deadb416788be678fb9cac22ea76dba83c946b0/gtk/gtk.go#L10718-L10723 |
26,464 | mattn/go-gtk | gtk/gtk.go | CanActivateAccel | func (v *Widget) CanActivateAccel(signal_id uint) bool {
return gobool(C.gtk_widget_can_activate_accel(v.GWidget, guint(signal_id)))
} | go | func (v *Widget) CanActivateAccel(signal_id uint) bool {
return gobool(C.gtk_widget_can_activate_accel(v.GWidget, guint(signal_id)))
} | [
"func",
"(",
"v",
"*",
"Widget",
")",
"CanActivateAccel",
"(",
"signal_id",
"uint",
")",
"bool",
"{",
"return",
"gobool",
"(",
"C",
".",
"gtk_widget_can_activate_accel",
"(",
"v",
".",
"GWidget",
",",
"guint",
"(",
"signal_id",
")",
")",
")",
"\n",
"}"
] | // gtk_widget_remove_accelerator
// gtk_widget_set_accel_path
// gtk_widget_list_accel_closures | [
"gtk_widget_remove_accelerator",
"gtk_widget_set_accel_path",
"gtk_widget_list_accel_closures"
] | 4deadb416788be678fb9cac22ea76dba83c946b0 | https://github.com/mattn/go-gtk/blob/4deadb416788be678fb9cac22ea76dba83c946b0/gtk/gtk.go#L10729-L10731 |
26,465 | mattn/go-gtk | gtk/gtk.go | GetPangoContext | func (v *Widget) GetPangoContext() *pango.Context {
return pango.ContextFromUnsafe(unsafe.Pointer(C.gtk_widget_get_pango_context((*C.GtkWidget)(v.GWidget))))
} | go | func (v *Widget) GetPangoContext() *pango.Context {
return pango.ContextFromUnsafe(unsafe.Pointer(C.gtk_widget_get_pango_context((*C.GtkWidget)(v.GWidget))))
} | [
"func",
"(",
"v",
"*",
"Widget",
")",
"GetPangoContext",
"(",
")",
"*",
"pango",
".",
"Context",
"{",
"return",
"pango",
".",
"ContextFromUnsafe",
"(",
"unsafe",
".",
"Pointer",
"(",
"C",
".",
"gtk_widget_get_pango_context",
"(",
"(",
"*",
"C",
".",
"Gtk... | // gtk_widget_reset_rc_styles
// gtk_widget_push_colormap
// gtk_widget_pop_colormap
// gtk_widget_set_default_colormap
// gtk_widget_get_default_style
// gtk_widget_get_default_colormap
// gtk_widget_get_default_visual
// gtk_widget_set_direction
// gtk_widget_get_direction
// gtk_widget_set_default_direction
// gtk_w... | [
"gtk_widget_reset_rc_styles",
"gtk_widget_push_colormap",
"gtk_widget_pop_colormap",
"gtk_widget_set_default_colormap",
"gtk_widget_get_default_style",
"gtk_widget_get_default_colormap",
"gtk_widget_get_default_visual",
"gtk_widget_set_direction",
"gtk_widget_get_direction",
"gtk_widget_set_defaul... | 4deadb416788be678fb9cac22ea76dba83c946b0 | https://github.com/mattn/go-gtk/blob/4deadb416788be678fb9cac22ea76dba83c946b0/gtk/gtk.go#L10856-L10858 |
26,466 | mattn/go-gtk | gtk/gtk.go | GetSizeRequest | func (v *Widget) GetSizeRequest() (width int, height int) {
var w, h C.gint
C.gtk_widget_get_size_request(v.GWidget, &w, &h)
return int(w), int(h)
} | go | func (v *Widget) GetSizeRequest() (width int, height int) {
var w, h C.gint
C.gtk_widget_get_size_request(v.GWidget, &w, &h)
return int(w), int(h)
} | [
"func",
"(",
"v",
"*",
"Widget",
")",
"GetSizeRequest",
"(",
")",
"(",
"width",
"int",
",",
"height",
"int",
")",
"{",
"var",
"w",
",",
"h",
"C",
".",
"gint",
"\n",
"C",
".",
"gtk_widget_get_size_request",
"(",
"v",
".",
"GWidget",
",",
"&",
"w",
... | // gtk_widget_get_clipboard
// gtk_widget_get_display
// gtk_widget_get_root_window
// gtk_widget_get_screen
// gtk_widget_has_screen | [
"gtk_widget_get_clipboard",
"gtk_widget_get_display",
"gtk_widget_get_root_window",
"gtk_widget_get_screen",
"gtk_widget_has_screen"
] | 4deadb416788be678fb9cac22ea76dba83c946b0 | https://github.com/mattn/go-gtk/blob/4deadb416788be678fb9cac22ea76dba83c946b0/gtk/gtk.go#L10938-L10942 |
26,467 | tjfoc/gmsm | sm2/pkcs7.go | UnmarshalSignedAttribute | func (p7 *PKCS7) UnmarshalSignedAttribute(attributeType asn1.ObjectIdentifier, out interface{}) error {
sd, ok := p7.raw.(signedData)
if !ok {
return errors.New("pkcs7: payload is not signedData content")
}
if len(sd.SignerInfos) < 1 {
return errors.New("pkcs7: payload has no signers")
}
attributes :=... | go | func (p7 *PKCS7) UnmarshalSignedAttribute(attributeType asn1.ObjectIdentifier, out interface{}) error {
sd, ok := p7.raw.(signedData)
if !ok {
return errors.New("pkcs7: payload is not signedData content")
}
if len(sd.SignerInfos) < 1 {
return errors.New("pkcs7: payload has no signers")
}
attributes :=... | [
"func",
"(",
"p7",
"*",
"PKCS7",
")",
"UnmarshalSignedAttribute",
"(",
"attributeType",
"asn1",
".",
"ObjectIdentifier",
",",
"out",
"interface",
"{",
"}",
")",
"error",
"{",
"sd",
",",
"ok",
":=",
"p7",
".",
"raw",
".",
"(",
"signedData",
")",
"\n",
"... | // UnmarshalSignedAttribute decodes a single attribute from the signer info | [
"UnmarshalSignedAttribute",
"decodes",
"a",
"single",
"attribute",
"from",
"the",
"signer",
"info"
] | 18fd8096dc8a3dcd43e9eccbdb4ef598900ae252 | https://github.com/tjfoc/gmsm/blob/18fd8096dc8a3dcd43e9eccbdb4ef598900ae252/sm2/pkcs7.go#L518-L528 |
26,468 | tjfoc/gmsm | sm2/pkcs7.go | NewSignedData | func NewSignedData(data []byte) (*SignedData, error) {
content, err := asn1.Marshal(data)
if err != nil {
return nil, err
}
ci := contentInfo{
ContentType: oidData,
Content: asn1.RawValue{Class: 2, Tag: 0, Bytes: content, IsCompound: true},
}
digAlg := pkix.AlgorithmIdentifier{
Algorithm: oi... | go | func NewSignedData(data []byte) (*SignedData, error) {
content, err := asn1.Marshal(data)
if err != nil {
return nil, err
}
ci := contentInfo{
ContentType: oidData,
Content: asn1.RawValue{Class: 2, Tag: 0, Bytes: content, IsCompound: true},
}
digAlg := pkix.AlgorithmIdentifier{
Algorithm: oi... | [
"func",
"NewSignedData",
"(",
"data",
"[",
"]",
"byte",
")",
"(",
"*",
"SignedData",
",",
"error",
")",
"{",
"content",
",",
"err",
":=",
"asn1",
".",
"Marshal",
"(",
"data",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
... | // NewSignedData initializes a SignedData with content | [
"NewSignedData",
"initializes",
"a",
"SignedData",
"with",
"content"
] | 18fd8096dc8a3dcd43e9eccbdb4ef598900ae252 | https://github.com/tjfoc/gmsm/blob/18fd8096dc8a3dcd43e9eccbdb4ef598900ae252/sm2/pkcs7.go#L550-L571 |
26,469 | tjfoc/gmsm | sm2/pkcs7.go | Add | func (attrs *attributes) Add(attrType asn1.ObjectIdentifier, value interface{}) {
attrs.types = append(attrs.types, attrType)
attrs.values = append(attrs.values, value)
} | go | func (attrs *attributes) Add(attrType asn1.ObjectIdentifier, value interface{}) {
attrs.types = append(attrs.types, attrType)
attrs.values = append(attrs.values, value)
} | [
"func",
"(",
"attrs",
"*",
"attributes",
")",
"Add",
"(",
"attrType",
"asn1",
".",
"ObjectIdentifier",
",",
"value",
"interface",
"{",
"}",
")",
"{",
"attrs",
".",
"types",
"=",
"append",
"(",
"attrs",
".",
"types",
",",
"attrType",
")",
"\n",
"attrs",... | // Add adds the attribute, maintaining insertion order | [
"Add",
"adds",
"the",
"attribute",
"maintaining",
"insertion",
"order"
] | 18fd8096dc8a3dcd43e9eccbdb4ef598900ae252 | https://github.com/tjfoc/gmsm/blob/18fd8096dc8a3dcd43e9eccbdb4ef598900ae252/sm2/pkcs7.go#L579-L582 |
26,470 | tjfoc/gmsm | sm2/pkcs7.go | Finish | func (sd *SignedData) Finish() ([]byte, error) {
sd.sd.Certificates = marshalCertificates(sd.certs)
inner, err := asn1.Marshal(sd.sd)
if err != nil {
return nil, err
}
outer := contentInfo{
ContentType: oidSignedData,
Content: asn1.RawValue{Class: 2, Tag: 0, Bytes: inner, IsCompound: true},
}
... | go | func (sd *SignedData) Finish() ([]byte, error) {
sd.sd.Certificates = marshalCertificates(sd.certs)
inner, err := asn1.Marshal(sd.sd)
if err != nil {
return nil, err
}
outer := contentInfo{
ContentType: oidSignedData,
Content: asn1.RawValue{Class: 2, Tag: 0, Bytes: inner, IsCompound: true},
}
... | [
"func",
"(",
"sd",
"*",
"SignedData",
")",
"Finish",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"sd",
".",
"sd",
".",
"Certificates",
"=",
"marshalCertificates",
"(",
"sd",
".",
"certs",
")",
"\n",
"inner",
",",
"err",
":=",
"asn1",
... | // Finish marshals the content and its signers | [
"Finish",
"marshals",
"the",
"content",
"and",
"its",
"signers"
] | 18fd8096dc8a3dcd43e9eccbdb4ef598900ae252 | https://github.com/tjfoc/gmsm/blob/18fd8096dc8a3dcd43e9eccbdb4ef598900ae252/sm2/pkcs7.go#L686-L697 |
26,471 | tjfoc/gmsm | sm2/pkcs7.go | signAttributes | func signAttributes(attrs []attribute, pkey crypto.PrivateKey, hash crypto.Hash) ([]byte, error) {
attrBytes, err := marshalAttributes(attrs)
if err != nil {
return nil, err
}
h := hash.New()
h.Write(attrBytes)
hashed := h.Sum(nil)
switch priv := pkey.(type) {
case *rsa.PrivateKey:
return rsa.Sign... | go | func signAttributes(attrs []attribute, pkey crypto.PrivateKey, hash crypto.Hash) ([]byte, error) {
attrBytes, err := marshalAttributes(attrs)
if err != nil {
return nil, err
}
h := hash.New()
h.Write(attrBytes)
hashed := h.Sum(nil)
switch priv := pkey.(type) {
case *rsa.PrivateKey:
return rsa.Sign... | [
"func",
"signAttributes",
"(",
"attrs",
"[",
"]",
"attribute",
",",
"pkey",
"crypto",
".",
"PrivateKey",
",",
"hash",
"crypto",
".",
"Hash",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"attrBytes",
",",
"err",
":=",
"marshalAttributes",
"(",
"a... | // signs the DER encoded form of the attributes with the private key | [
"signs",
"the",
"DER",
"encoded",
"form",
"of",
"the",
"attributes",
"with",
"the",
"private",
"key"
] | 18fd8096dc8a3dcd43e9eccbdb4ef598900ae252 | https://github.com/tjfoc/gmsm/blob/18fd8096dc8a3dcd43e9eccbdb4ef598900ae252/sm2/pkcs7.go#L710-L723 |
26,472 | tjfoc/gmsm | sm2/pkcs7.go | marshalCertificates | func marshalCertificates(certs []*Certificate) rawCertificates {
var buf bytes.Buffer
for _, cert := range certs {
buf.Write(cert.Raw)
}
rawCerts, _ := marshalCertificateBytes(buf.Bytes())
return rawCerts
} | go | func marshalCertificates(certs []*Certificate) rawCertificates {
var buf bytes.Buffer
for _, cert := range certs {
buf.Write(cert.Raw)
}
rawCerts, _ := marshalCertificateBytes(buf.Bytes())
return rawCerts
} | [
"func",
"marshalCertificates",
"(",
"certs",
"[",
"]",
"*",
"Certificate",
")",
"rawCertificates",
"{",
"var",
"buf",
"bytes",
".",
"Buffer",
"\n",
"for",
"_",
",",
"cert",
":=",
"range",
"certs",
"{",
"buf",
".",
"Write",
"(",
"cert",
".",
"Raw",
")",... | // concats and wraps the certificates in the RawValue structure | [
"concats",
"and",
"wraps",
"the",
"certificates",
"in",
"the",
"RawValue",
"structure"
] | 18fd8096dc8a3dcd43e9eccbdb4ef598900ae252 | https://github.com/tjfoc/gmsm/blob/18fd8096dc8a3dcd43e9eccbdb4ef598900ae252/sm2/pkcs7.go#L726-L733 |
26,473 | tjfoc/gmsm | sm2/pkcs7.go | DegenerateCertificate | func DegenerateCertificate(cert []byte) ([]byte, error) {
rawCert, err := marshalCertificateBytes(cert)
if err != nil {
return nil, err
}
emptyContent := contentInfo{ContentType: oidData}
sd := signedData{
Version: 1,
ContentInfo: emptyContent,
Certificates: rawCert,
CRLs: []pkix.... | go | func DegenerateCertificate(cert []byte) ([]byte, error) {
rawCert, err := marshalCertificateBytes(cert)
if err != nil {
return nil, err
}
emptyContent := contentInfo{ContentType: oidData}
sd := signedData{
Version: 1,
ContentInfo: emptyContent,
Certificates: rawCert,
CRLs: []pkix.... | [
"func",
"DegenerateCertificate",
"(",
"cert",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"rawCert",
",",
"err",
":=",
"marshalCertificateBytes",
"(",
"cert",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"... | // DegenerateCertificate creates a signed data structure containing only the
// provided certificate or certificate chain. | [
"DegenerateCertificate",
"creates",
"a",
"signed",
"data",
"structure",
"containing",
"only",
"the",
"provided",
"certificate",
"or",
"certificate",
"chain",
"."
] | 18fd8096dc8a3dcd43e9eccbdb4ef598900ae252 | https://github.com/tjfoc/gmsm/blob/18fd8096dc8a3dcd43e9eccbdb4ef598900ae252/sm2/pkcs7.go#L749-L770 |
26,474 | tjfoc/gmsm | sm2/pkcs1.go | MarshalPKCS1PrivateKey | func MarshalPKCS1PrivateKey(key *rsa.PrivateKey) []byte {
key.Precompute()
version := 0
if len(key.Primes) > 2 {
version = 1
}
priv := pkcs1PrivateKey{
Version: version,
N: key.N,
E: key.PublicKey.E,
D: key.D,
P: key.Primes[0],
Q: key.Primes[1],
Dp: key.Precompu... | go | func MarshalPKCS1PrivateKey(key *rsa.PrivateKey) []byte {
key.Precompute()
version := 0
if len(key.Primes) > 2 {
version = 1
}
priv := pkcs1PrivateKey{
Version: version,
N: key.N,
E: key.PublicKey.E,
D: key.D,
P: key.Primes[0],
Q: key.Primes[1],
Dp: key.Precompu... | [
"func",
"MarshalPKCS1PrivateKey",
"(",
"key",
"*",
"rsa",
".",
"PrivateKey",
")",
"[",
"]",
"byte",
"{",
"key",
".",
"Precompute",
"(",
")",
"\n\n",
"version",
":=",
"0",
"\n",
"if",
"len",
"(",
"key",
".",
"Primes",
")",
">",
"2",
"{",
"version",
... | // MarshalPKCS1PrivateKey converts a private key to ASN.1 DER encoded form. | [
"MarshalPKCS1PrivateKey",
"converts",
"a",
"private",
"key",
"to",
"ASN",
".",
"1",
"DER",
"encoded",
"form",
"."
] | 18fd8096dc8a3dcd43e9eccbdb4ef598900ae252 | https://github.com/tjfoc/gmsm/blob/18fd8096dc8a3dcd43e9eccbdb4ef598900ae252/sm2/pkcs1.go#L97-L126 |
26,475 | tjfoc/gmsm | sm2/p256.go | IsOnCurve | func (curve sm2P256Curve) IsOnCurve(X, Y *big.Int) bool {
var a, x, y, y2, x3 sm2P256FieldElement
sm2P256FromBig(&x, X)
sm2P256FromBig(&y, Y)
sm2P256Square(&x3, &x) // x3 = x ^ 2
sm2P256Mul(&x3, &x3, &x) // x3 = x ^ 2 * x
sm2P256Mul(&a, &curve.a, &x) // a = a * x
sm2P256Add(&x3, &x3, &a)
sm2P256Add(... | go | func (curve sm2P256Curve) IsOnCurve(X, Y *big.Int) bool {
var a, x, y, y2, x3 sm2P256FieldElement
sm2P256FromBig(&x, X)
sm2P256FromBig(&y, Y)
sm2P256Square(&x3, &x) // x3 = x ^ 2
sm2P256Mul(&x3, &x3, &x) // x3 = x ^ 2 * x
sm2P256Mul(&a, &curve.a, &x) // a = a * x
sm2P256Add(&x3, &x3, &a)
sm2P256Add(... | [
"func",
"(",
"curve",
"sm2P256Curve",
")",
"IsOnCurve",
"(",
"X",
",",
"Y",
"*",
"big",
".",
"Int",
")",
"bool",
"{",
"var",
"a",
",",
"x",
",",
"y",
",",
"y2",
",",
"x3",
"sm2P256FieldElement",
"\n\n",
"sm2P256FromBig",
"(",
"&",
"x",
",",
"X",
... | // y^2 = x^3 + ax + b | [
"y^2",
"=",
"x^3",
"+",
"ax",
"+",
"b"
] | 18fd8096dc8a3dcd43e9eccbdb4ef598900ae252 | https://github.com/tjfoc/gmsm/blob/18fd8096dc8a3dcd43e9eccbdb4ef598900ae252/sm2/p256.go#L93-L107 |
26,476 | tjfoc/gmsm | sm2/p256.go | sm2P256GetBit | func sm2P256GetBit(scalar *[32]uint8, bit uint) uint32 {
return uint32(((scalar[bit>>3]) >> (bit & 7)) & 1)
} | go | func sm2P256GetBit(scalar *[32]uint8, bit uint) uint32 {
return uint32(((scalar[bit>>3]) >> (bit & 7)) & 1)
} | [
"func",
"sm2P256GetBit",
"(",
"scalar",
"*",
"[",
"32",
"]",
"uint8",
",",
"bit",
"uint",
")",
"uint32",
"{",
"return",
"uint32",
"(",
"(",
"(",
"scalar",
"[",
"bit",
">>",
"3",
"]",
")",
">>",
"(",
"bit",
"&",
"7",
")",
")",
"&",
"1",
")",
"... | // sm2P256GetBit returns the bit'th bit of scalar. | [
"sm2P256GetBit",
"returns",
"the",
"bit",
"th",
"bit",
"of",
"scalar",
"."
] | 18fd8096dc8a3dcd43e9eccbdb4ef598900ae252 | https://github.com/tjfoc/gmsm/blob/18fd8096dc8a3dcd43e9eccbdb4ef598900ae252/sm2/p256.go#L343-L345 |
26,477 | tjfoc/gmsm | sm2/p256.go | sm2P256Add | func sm2P256Add(c, a, b *sm2P256FieldElement) {
carry := uint32(0)
for i := 0; ; i++ {
c[i] = a[i] + b[i]
c[i] += carry
carry = c[i] >> 29
c[i] &= bottom29Bits
i++
if i == 9 {
break
}
c[i] = a[i] + b[i]
c[i] += carry
carry = c[i] >> 28
c[i] &= bottom28Bits
}
sm2P256ReduceCarry(c, carry)
} | go | func sm2P256Add(c, a, b *sm2P256FieldElement) {
carry := uint32(0)
for i := 0; ; i++ {
c[i] = a[i] + b[i]
c[i] += carry
carry = c[i] >> 29
c[i] &= bottom29Bits
i++
if i == 9 {
break
}
c[i] = a[i] + b[i]
c[i] += carry
carry = c[i] >> 28
c[i] &= bottom28Bits
}
sm2P256ReduceCarry(c, carry)
} | [
"func",
"sm2P256Add",
"(",
"c",
",",
"a",
",",
"b",
"*",
"sm2P256FieldElement",
")",
"{",
"carry",
":=",
"uint32",
"(",
"0",
")",
"\n",
"for",
"i",
":=",
"0",
";",
";",
"i",
"++",
"{",
"c",
"[",
"i",
"]",
"=",
"a",
"[",
"i",
"]",
"+",
"b",
... | // c = a + b | [
"c",
"=",
"a",
"+",
"b"
] | 18fd8096dc8a3dcd43e9eccbdb4ef598900ae252 | https://github.com/tjfoc/gmsm/blob/18fd8096dc8a3dcd43e9eccbdb4ef598900ae252/sm2/p256.go#L602-L619 |
26,478 | tjfoc/gmsm | sm2/p256.go | sm2P256Sub | func sm2P256Sub(c, a, b *sm2P256FieldElement) {
var carry uint32
for i := 0; ; i++ {
c[i] = a[i] - b[i]
c[i] += sm2P256Zero31[i]
c[i] += carry
carry = c[i] >> 29
c[i] &= bottom29Bits
i++
if i == 9 {
break
}
c[i] = a[i] - b[i]
c[i] += sm2P256Zero31[i]
c[i] += carry
carry = c[i] >> 28
c[i]... | go | func sm2P256Sub(c, a, b *sm2P256FieldElement) {
var carry uint32
for i := 0; ; i++ {
c[i] = a[i] - b[i]
c[i] += sm2P256Zero31[i]
c[i] += carry
carry = c[i] >> 29
c[i] &= bottom29Bits
i++
if i == 9 {
break
}
c[i] = a[i] - b[i]
c[i] += sm2P256Zero31[i]
c[i] += carry
carry = c[i] >> 28
c[i]... | [
"func",
"sm2P256Sub",
"(",
"c",
",",
"a",
",",
"b",
"*",
"sm2P256FieldElement",
")",
"{",
"var",
"carry",
"uint32",
"\n\n",
"for",
"i",
":=",
"0",
";",
";",
"i",
"++",
"{",
"c",
"[",
"i",
"]",
"=",
"a",
"[",
"i",
"]",
"-",
"b",
"[",
"i",
"]... | // c = a - b | [
"c",
"=",
"a",
"-",
"b"
] | 18fd8096dc8a3dcd43e9eccbdb4ef598900ae252 | https://github.com/tjfoc/gmsm/blob/18fd8096dc8a3dcd43e9eccbdb4ef598900ae252/sm2/p256.go#L622-L642 |
26,479 | tjfoc/gmsm | sm2/p256.go | sm2P256ReduceCarry | func sm2P256ReduceCarry(a *sm2P256FieldElement, carry uint32) {
a[0] += sm2P256Carry[carry*9+0]
a[2] += sm2P256Carry[carry*9+2]
a[3] += sm2P256Carry[carry*9+3]
a[7] += sm2P256Carry[carry*9+7]
} | go | func sm2P256ReduceCarry(a *sm2P256FieldElement, carry uint32) {
a[0] += sm2P256Carry[carry*9+0]
a[2] += sm2P256Carry[carry*9+2]
a[3] += sm2P256Carry[carry*9+3]
a[7] += sm2P256Carry[carry*9+7]
} | [
"func",
"sm2P256ReduceCarry",
"(",
"a",
"*",
"sm2P256FieldElement",
",",
"carry",
"uint32",
")",
"{",
"a",
"[",
"0",
"]",
"+=",
"sm2P256Carry",
"[",
"carry",
"*",
"9",
"+",
"0",
"]",
"\n",
"a",
"[",
"2",
"]",
"+=",
"sm2P256Carry",
"[",
"carry",
"*",
... | // carry < 2 ^ 3 | [
"carry",
"<",
"2",
"^",
"3"
] | 18fd8096dc8a3dcd43e9eccbdb4ef598900ae252 | https://github.com/tjfoc/gmsm/blob/18fd8096dc8a3dcd43e9eccbdb4ef598900ae252/sm2/p256.go#L807-L812 |
26,480 | tjfoc/gmsm | sm3/sm3.go | Sum | func (sm3 *SM3) Sum(in []byte) []byte {
sm3.Write(in)
msg := sm3.pad()
// Finialize
sm3.update(msg, len(msg)/sm3.BlockSize())
// save hash to in
needed := sm3.Size()
if cap(in)-len(in) < needed {
newIn := make([]byte, len(in), len(in)+needed)
copy(newIn, in)
in = newIn
}
out := in[len(in) : len(in)+nee... | go | func (sm3 *SM3) Sum(in []byte) []byte {
sm3.Write(in)
msg := sm3.pad()
// Finialize
sm3.update(msg, len(msg)/sm3.BlockSize())
// save hash to in
needed := sm3.Size()
if cap(in)-len(in) < needed {
newIn := make([]byte, len(in), len(in)+needed)
copy(newIn, in)
in = newIn
}
out := in[len(in) : len(in)+nee... | [
"func",
"(",
"sm3",
"*",
"SM3",
")",
"Sum",
"(",
"in",
"[",
"]",
"byte",
")",
"[",
"]",
"byte",
"{",
"sm3",
".",
"Write",
"(",
"in",
")",
"\n",
"msg",
":=",
"sm3",
".",
"pad",
"(",
")",
"\n\n",
"// Finialize",
"sm3",
".",
"update",
"(",
"msg"... | // Sum, required by the hash.Hash interface.
// Sum appends the current hash to b and returns the resulting slice.
// It does not change the underlying hash state. | [
"Sum",
"required",
"by",
"the",
"hash",
".",
"Hash",
"interface",
".",
"Sum",
"appends",
"the",
"current",
"hash",
"to",
"b",
"and",
"returns",
"the",
"resulting",
"slice",
".",
"It",
"does",
"not",
"change",
"the",
"underlying",
"hash",
"state",
"."
] | 18fd8096dc8a3dcd43e9eccbdb4ef598900ae252 | https://github.com/tjfoc/gmsm/blob/18fd8096dc8a3dcd43e9eccbdb4ef598900ae252/sm3/sm3.go#L178-L199 |
26,481 | tjfoc/gmsm | sm4/sm4.go | NewCipher | func NewCipher(key []byte) (cipher.Block, error) {
if len(key) != BlockSize {
return nil, KeySizeError(len(key))
}
c := new(Sm4Cipher)
c.subkeys = generateSubKeys(key)
c.block1 = make([]uint32, 4)
c.block2 = make([]byte, 16)
return c, nil
} | go | func NewCipher(key []byte) (cipher.Block, error) {
if len(key) != BlockSize {
return nil, KeySizeError(len(key))
}
c := new(Sm4Cipher)
c.subkeys = generateSubKeys(key)
c.block1 = make([]uint32, 4)
c.block2 = make([]byte, 16)
return c, nil
} | [
"func",
"NewCipher",
"(",
"key",
"[",
"]",
"byte",
")",
"(",
"cipher",
".",
"Block",
",",
"error",
")",
"{",
"if",
"len",
"(",
"key",
")",
"!=",
"BlockSize",
"{",
"return",
"nil",
",",
"KeySizeError",
"(",
"len",
"(",
"key",
")",
")",
"\n",
"}",
... | // NewCipher creates and returns a new cipher.Block. | [
"NewCipher",
"creates",
"and",
"returns",
"a",
"new",
"cipher",
".",
"Block",
"."
] | 18fd8096dc8a3dcd43e9eccbdb4ef598900ae252 | https://github.com/tjfoc/gmsm/blob/18fd8096dc8a3dcd43e9eccbdb4ef598900ae252/sm4/sm4.go#L321-L330 |
26,482 | tjfoc/gmsm | sm2/cert_pool.go | NewCertPool | func NewCertPool() *CertPool {
return &CertPool{
bySubjectKeyId: make(map[string][]int),
byName: make(map[string][]int),
}
} | go | func NewCertPool() *CertPool {
return &CertPool{
bySubjectKeyId: make(map[string][]int),
byName: make(map[string][]int),
}
} | [
"func",
"NewCertPool",
"(",
")",
"*",
"CertPool",
"{",
"return",
"&",
"CertPool",
"{",
"bySubjectKeyId",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"[",
"]",
"int",
")",
",",
"byName",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"[",
"]",
"int",... | // NewCertPool returns a new, empty CertPool. | [
"NewCertPool",
"returns",
"a",
"new",
"empty",
"CertPool",
"."
] | 18fd8096dc8a3dcd43e9eccbdb4ef598900ae252 | https://github.com/tjfoc/gmsm/blob/18fd8096dc8a3dcd43e9eccbdb4ef598900ae252/sm2/cert_pool.go#L44-L49 |
26,483 | tjfoc/gmsm | sm2/cert_pool.go | findVerifiedParents | func (s *CertPool) findVerifiedParents(cert *Certificate) (parents []int, errCert *Certificate, err error) {
if s == nil {
return
}
var candidates []int
if len(cert.AuthorityKeyId) > 0 {
candidates = s.bySubjectKeyId[string(cert.AuthorityKeyId)]
}
if len(candidates) == 0 {
candidates = s.byName[string(cert... | go | func (s *CertPool) findVerifiedParents(cert *Certificate) (parents []int, errCert *Certificate, err error) {
if s == nil {
return
}
var candidates []int
if len(cert.AuthorityKeyId) > 0 {
candidates = s.bySubjectKeyId[string(cert.AuthorityKeyId)]
}
if len(candidates) == 0 {
candidates = s.byName[string(cert... | [
"func",
"(",
"s",
"*",
"CertPool",
")",
"findVerifiedParents",
"(",
"cert",
"*",
"Certificate",
")",
"(",
"parents",
"[",
"]",
"int",
",",
"errCert",
"*",
"Certificate",
",",
"err",
"error",
")",
"{",
"if",
"s",
"==",
"nil",
"{",
"return",
"\n",
"}",... | // findVerifiedParents attempts to find certificates in s which have signed the
// given certificate. If any candidates were rejected then errCert will be set
// to one of them, arbitrarily, and err will contain the reason that it was
// rejected. | [
"findVerifiedParents",
"attempts",
"to",
"find",
"certificates",
"in",
"s",
"which",
"have",
"signed",
"the",
"given",
"certificate",
".",
"If",
"any",
"candidates",
"were",
"rejected",
"then",
"errCert",
"will",
"be",
"set",
"to",
"one",
"of",
"them",
"arbitr... | 18fd8096dc8a3dcd43e9eccbdb4ef598900ae252 | https://github.com/tjfoc/gmsm/blob/18fd8096dc8a3dcd43e9eccbdb4ef598900ae252/sm2/cert_pool.go#L131-L153 |
26,484 | tjfoc/gmsm | sm2/cert_pool.go | AddCert | func (s *CertPool) AddCert(cert *Certificate) {
if cert == nil {
panic("adding nil Certificate to CertPool")
}
// Check that the certificate isn't being added twice.
if s.contains(cert) {
return
}
n := len(s.certs)
s.certs = append(s.certs, cert)
if len(cert.SubjectKeyId) > 0 {
keyId := string(cert.Sub... | go | func (s *CertPool) AddCert(cert *Certificate) {
if cert == nil {
panic("adding nil Certificate to CertPool")
}
// Check that the certificate isn't being added twice.
if s.contains(cert) {
return
}
n := len(s.certs)
s.certs = append(s.certs, cert)
if len(cert.SubjectKeyId) > 0 {
keyId := string(cert.Sub... | [
"func",
"(",
"s",
"*",
"CertPool",
")",
"AddCert",
"(",
"cert",
"*",
"Certificate",
")",
"{",
"if",
"cert",
"==",
"nil",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"// Check that the certificate isn't being added twice.",
"if",
"s",
".",
"conta... | // AddCert adds a certificate to a pool. | [
"AddCert",
"adds",
"a",
"certificate",
"to",
"a",
"pool",
"."
] | 18fd8096dc8a3dcd43e9eccbdb4ef598900ae252 | https://github.com/tjfoc/gmsm/blob/18fd8096dc8a3dcd43e9eccbdb4ef598900ae252/sm2/cert_pool.go#L171-L190 |
26,485 | tjfoc/gmsm | sm2/cert_pool.go | Subjects | func (s *CertPool) Subjects() [][]byte {
res := make([][]byte, len(s.certs))
for i, c := range s.certs {
res[i] = c.RawSubject
}
return res
} | go | func (s *CertPool) Subjects() [][]byte {
res := make([][]byte, len(s.certs))
for i, c := range s.certs {
res[i] = c.RawSubject
}
return res
} | [
"func",
"(",
"s",
"*",
"CertPool",
")",
"Subjects",
"(",
")",
"[",
"]",
"[",
"]",
"byte",
"{",
"res",
":=",
"make",
"(",
"[",
"]",
"[",
"]",
"byte",
",",
"len",
"(",
"s",
".",
"certs",
")",
")",
"\n",
"for",
"i",
",",
"c",
":=",
"range",
... | // Subjects returns a list of the DER-encoded subjects of
// all of the certificates in the pool. | [
"Subjects",
"returns",
"a",
"list",
"of",
"the",
"DER",
"-",
"encoded",
"subjects",
"of",
"all",
"of",
"the",
"certificates",
"in",
"the",
"pool",
"."
] | 18fd8096dc8a3dcd43e9eccbdb4ef598900ae252 | https://github.com/tjfoc/gmsm/blob/18fd8096dc8a3dcd43e9eccbdb4ef598900ae252/sm2/cert_pool.go#L223-L229 |
26,486 | tjfoc/gmsm | sm2/verify.go | isValid | func (c *Certificate) isValid(certType int, currentChain []*Certificate, opts *VerifyOptions) error {
if len(currentChain) > 0 {
child := currentChain[len(currentChain)-1]
if !bytes.Equal(child.RawIssuer, c.RawSubject) {
return CertificateInvalidError{c, NameMismatch}
}
}
now := opts.CurrentTime
if now.IsZ... | go | func (c *Certificate) isValid(certType int, currentChain []*Certificate, opts *VerifyOptions) error {
if len(currentChain) > 0 {
child := currentChain[len(currentChain)-1]
if !bytes.Equal(child.RawIssuer, c.RawSubject) {
return CertificateInvalidError{c, NameMismatch}
}
}
now := opts.CurrentTime
if now.IsZ... | [
"func",
"(",
"c",
"*",
"Certificate",
")",
"isValid",
"(",
"certType",
"int",
",",
"currentChain",
"[",
"]",
"*",
"Certificate",
",",
"opts",
"*",
"VerifyOptions",
")",
"error",
"{",
"if",
"len",
"(",
"currentChain",
")",
">",
"0",
"{",
"child",
":=",
... | // isValid performs validity checks on the c. | [
"isValid",
"performs",
"validity",
"checks",
"on",
"the",
"c",
"."
] | 18fd8096dc8a3dcd43e9eccbdb4ef598900ae252 | https://github.com/tjfoc/gmsm/blob/18fd8096dc8a3dcd43e9eccbdb4ef598900ae252/sm2/verify.go#L204-L261 |
26,487 | tjfoc/gmsm | sm2/verify.go | toLowerCaseASCII | func toLowerCaseASCII(in string) string {
// If the string is already lower-case then there's nothing to do.
isAlreadyLowerCase := true
for _, c := range in {
if c == utf8.RuneError {
// If we get a UTF-8 error then there might be
// upper-case ASCII bytes in the invalid sequence.
isAlreadyLowerCase = fal... | go | func toLowerCaseASCII(in string) string {
// If the string is already lower-case then there's nothing to do.
isAlreadyLowerCase := true
for _, c := range in {
if c == utf8.RuneError {
// If we get a UTF-8 error then there might be
// upper-case ASCII bytes in the invalid sequence.
isAlreadyLowerCase = fal... | [
"func",
"toLowerCaseASCII",
"(",
"in",
"string",
")",
"string",
"{",
"// If the string is already lower-case then there's nothing to do.",
"isAlreadyLowerCase",
":=",
"true",
"\n",
"for",
"_",
",",
"c",
":=",
"range",
"in",
"{",
"if",
"c",
"==",
"utf8",
".",
"Rune... | // toLowerCaseASCII returns a lower-case version of in. See RFC 6125 6.4.1. We use
// an explicitly ASCII function to avoid any sharp corners resulting from
// performing Unicode operations on DNS labels. | [
"toLowerCaseASCII",
"returns",
"a",
"lower",
"-",
"case",
"version",
"of",
"in",
".",
"See",
"RFC",
"6125",
"6",
".",
"4",
".",
"1",
".",
"We",
"use",
"an",
"explicitly",
"ASCII",
"function",
"to",
"avoid",
"any",
"sharp",
"corners",
"resulting",
"from",... | 18fd8096dc8a3dcd43e9eccbdb4ef598900ae252 | https://github.com/tjfoc/gmsm/blob/18fd8096dc8a3dcd43e9eccbdb4ef598900ae252/sm2/verify.go#L444-L471 |
26,488 | tjfoc/gmsm | sm2/verify.go | VerifyHostname | func (c *Certificate) VerifyHostname(h string) error {
// IP addresses may be written in [ ].
candidateIP := h
if len(h) >= 3 && h[0] == '[' && h[len(h)-1] == ']' {
candidateIP = h[1 : len(h)-1]
}
if ip := net.ParseIP(candidateIP); ip != nil {
// We only match IP addresses against IP SANs.
// https://tools.i... | go | func (c *Certificate) VerifyHostname(h string) error {
// IP addresses may be written in [ ].
candidateIP := h
if len(h) >= 3 && h[0] == '[' && h[len(h)-1] == ']' {
candidateIP = h[1 : len(h)-1]
}
if ip := net.ParseIP(candidateIP); ip != nil {
// We only match IP addresses against IP SANs.
// https://tools.i... | [
"func",
"(",
"c",
"*",
"Certificate",
")",
"VerifyHostname",
"(",
"h",
"string",
")",
"error",
"{",
"// IP addresses may be written in [ ].",
"candidateIP",
":=",
"h",
"\n",
"if",
"len",
"(",
"h",
")",
">=",
"3",
"&&",
"h",
"[",
"0",
"]",
"==",
"'['",
... | // VerifyHostname returns nil if c is a valid certificate for the named host.
// Otherwise it returns an error describing the mismatch. | [
"VerifyHostname",
"returns",
"nil",
"if",
"c",
"is",
"a",
"valid",
"certificate",
"for",
"the",
"named",
"host",
".",
"Otherwise",
"it",
"returns",
"an",
"error",
"describing",
"the",
"mismatch",
"."
] | 18fd8096dc8a3dcd43e9eccbdb4ef598900ae252 | https://github.com/tjfoc/gmsm/blob/18fd8096dc8a3dcd43e9eccbdb4ef598900ae252/sm2/verify.go#L475-L506 |
26,489 | tjfoc/gmsm | sm2/x509.go | MarshalPKIXPublicKey | func MarshalPKIXPublicKey(pub interface{}) ([]byte, error) {
var publicKeyBytes []byte
var publicKeyAlgorithm pkix.AlgorithmIdentifier
var err error
if publicKeyBytes, publicKeyAlgorithm, err = marshalPublicKey(pub); err != nil {
return nil, err
}
pkix := pkixPublicKey{
Algo: publicKeyAlgorithm,
BitString... | go | func MarshalPKIXPublicKey(pub interface{}) ([]byte, error) {
var publicKeyBytes []byte
var publicKeyAlgorithm pkix.AlgorithmIdentifier
var err error
if publicKeyBytes, publicKeyAlgorithm, err = marshalPublicKey(pub); err != nil {
return nil, err
}
pkix := pkixPublicKey{
Algo: publicKeyAlgorithm,
BitString... | [
"func",
"MarshalPKIXPublicKey",
"(",
"pub",
"interface",
"{",
"}",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"var",
"publicKeyBytes",
"[",
"]",
"byte",
"\n",
"var",
"publicKeyAlgorithm",
"pkix",
".",
"AlgorithmIdentifier",
"\n",
"var",
"err",
"er... | // MarshalPKIXPublicKey serialises a public key to DER-encoded PKIX format. | [
"MarshalPKIXPublicKey",
"serialises",
"a",
"public",
"key",
"to",
"DER",
"-",
"encoded",
"PKIX",
"format",
"."
] | 18fd8096dc8a3dcd43e9eccbdb4ef598900ae252 | https://github.com/tjfoc/gmsm/blob/18fd8096dc8a3dcd43e9eccbdb4ef598900ae252/sm2/x509.go#L130-L149 |
26,490 | tjfoc/gmsm | sm2/x509.go | rsaPSSParameters | func rsaPSSParameters(hashFunc Hash) asn1.RawValue {
var hashOID asn1.ObjectIdentifier
switch hashFunc {
case SHA256:
hashOID = oidSHA256
case SHA384:
hashOID = oidSHA384
case SHA512:
hashOID = oidSHA512
}
params := pssParameters{
Hash: pkix.AlgorithmIdentifier{
Algorithm: hashOID,
Parameters: as... | go | func rsaPSSParameters(hashFunc Hash) asn1.RawValue {
var hashOID asn1.ObjectIdentifier
switch hashFunc {
case SHA256:
hashOID = oidSHA256
case SHA384:
hashOID = oidSHA384
case SHA512:
hashOID = oidSHA512
}
params := pssParameters{
Hash: pkix.AlgorithmIdentifier{
Algorithm: hashOID,
Parameters: as... | [
"func",
"rsaPSSParameters",
"(",
"hashFunc",
"Hash",
")",
"asn1",
".",
"RawValue",
"{",
"var",
"hashOID",
"asn1",
".",
"ObjectIdentifier",
"\n\n",
"switch",
"hashFunc",
"{",
"case",
"SHA256",
":",
"hashOID",
"=",
"oidSHA256",
"\n",
"case",
"SHA384",
":",
"ha... | // rsaPSSParameters returns an asn1.RawValue suitable for use as the Parameters
// in an AlgorithmIdentifier that specifies RSA PSS. | [
"rsaPSSParameters",
"returns",
"an",
"asn1",
".",
"RawValue",
"suitable",
"for",
"use",
"as",
"the",
"Parameters",
"in",
"an",
"AlgorithmIdentifier",
"that",
"specifies",
"RSA",
"PSS",
"."
] | 18fd8096dc8a3dcd43e9eccbdb4ef598900ae252 | https://github.com/tjfoc/gmsm/blob/18fd8096dc8a3dcd43e9eccbdb4ef598900ae252/sm2/x509.go#L500-L545 |
26,491 | tjfoc/gmsm | sm2/x509.go | CheckSignatureFrom | func (c *Certificate) CheckSignatureFrom(parent *Certificate) error {
// RFC 5280, 4.2.1.9:
// "If the basic constraints extension is not present in a version 3
// certificate, or the extension is present but the cA boolean is not
// asserted, then the certified public key MUST NOT be used to verify
// certificate... | go | func (c *Certificate) CheckSignatureFrom(parent *Certificate) error {
// RFC 5280, 4.2.1.9:
// "If the basic constraints extension is not present in a version 3
// certificate, or the extension is present but the cA boolean is not
// asserted, then the certified public key MUST NOT be used to verify
// certificate... | [
"func",
"(",
"c",
"*",
"Certificate",
")",
"CheckSignatureFrom",
"(",
"parent",
"*",
"Certificate",
")",
"error",
"{",
"// RFC 5280, 4.2.1.9:",
"// \"If the basic constraints extension is not present in a version 3",
"// certificate, or the extension is present but the cA boolean is ... | // CheckSignatureFrom verifies that the signature on c is a valid signature
// from parent. | [
"CheckSignatureFrom",
"verifies",
"that",
"the",
"signature",
"on",
"c",
"is",
"a",
"valid",
"signature",
"from",
"parent",
"."
] | 18fd8096dc8a3dcd43e9eccbdb4ef598900ae252 | https://github.com/tjfoc/gmsm/blob/18fd8096dc8a3dcd43e9eccbdb4ef598900ae252/sm2/x509.go#L937-L961 |
26,492 | tjfoc/gmsm | sm2/x509.go | CheckSignature | func (c *Certificate) CheckSignature(algo SignatureAlgorithm, signed, signature []byte) error {
return checkSignature(algo, signed, signature, c.PublicKey)
} | go | func (c *Certificate) CheckSignature(algo SignatureAlgorithm, signed, signature []byte) error {
return checkSignature(algo, signed, signature, c.PublicKey)
} | [
"func",
"(",
"c",
"*",
"Certificate",
")",
"CheckSignature",
"(",
"algo",
"SignatureAlgorithm",
",",
"signed",
",",
"signature",
"[",
"]",
"byte",
")",
"error",
"{",
"return",
"checkSignature",
"(",
"algo",
",",
"signed",
",",
"signature",
",",
"c",
".",
... | // CheckSignature verifies that signature is a valid signature over signed from
// c's public key. | [
"CheckSignature",
"verifies",
"that",
"signature",
"is",
"a",
"valid",
"signature",
"over",
"signed",
"from",
"c",
"s",
"public",
"key",
"."
] | 18fd8096dc8a3dcd43e9eccbdb4ef598900ae252 | https://github.com/tjfoc/gmsm/blob/18fd8096dc8a3dcd43e9eccbdb4ef598900ae252/sm2/x509.go#L965-L967 |
26,493 | tjfoc/gmsm | sm2/x509.go | CheckCRLSignature | func (c *Certificate) CheckCRLSignature(crl *pkix.CertificateList) error {
algo := getSignatureAlgorithmFromAI(crl.SignatureAlgorithm)
return c.CheckSignature(algo, crl.TBSCertList.Raw, crl.SignatureValue.RightAlign())
} | go | func (c *Certificate) CheckCRLSignature(crl *pkix.CertificateList) error {
algo := getSignatureAlgorithmFromAI(crl.SignatureAlgorithm)
return c.CheckSignature(algo, crl.TBSCertList.Raw, crl.SignatureValue.RightAlign())
} | [
"func",
"(",
"c",
"*",
"Certificate",
")",
"CheckCRLSignature",
"(",
"crl",
"*",
"pkix",
".",
"CertificateList",
")",
"error",
"{",
"algo",
":=",
"getSignatureAlgorithmFromAI",
"(",
"crl",
".",
"SignatureAlgorithm",
")",
"\n",
"return",
"c",
".",
"CheckSignatu... | // CheckCRLSignature checks that the signature in crl is from c. | [
"CheckCRLSignature",
"checks",
"that",
"the",
"signature",
"in",
"crl",
"is",
"from",
"c",
"."
] | 18fd8096dc8a3dcd43e9eccbdb4ef598900ae252 | https://github.com/tjfoc/gmsm/blob/18fd8096dc8a3dcd43e9eccbdb4ef598900ae252/sm2/x509.go#L1050-L1053 |
26,494 | tjfoc/gmsm | sm2/x509.go | ParseCertificate | func ParseCertificate(asn1Data []byte) (*Certificate, error) {
var cert certificate
rest, err := asn1.Unmarshal(asn1Data, &cert)
if err != nil {
return nil, err
}
if len(rest) > 0 {
return nil, asn1.SyntaxError{Msg: "trailing data"}
}
return parseCertificate(&cert)
} | go | func ParseCertificate(asn1Data []byte) (*Certificate, error) {
var cert certificate
rest, err := asn1.Unmarshal(asn1Data, &cert)
if err != nil {
return nil, err
}
if len(rest) > 0 {
return nil, asn1.SyntaxError{Msg: "trailing data"}
}
return parseCertificate(&cert)
} | [
"func",
"ParseCertificate",
"(",
"asn1Data",
"[",
"]",
"byte",
")",
"(",
"*",
"Certificate",
",",
"error",
")",
"{",
"var",
"cert",
"certificate",
"\n",
"rest",
",",
"err",
":=",
"asn1",
".",
"Unmarshal",
"(",
"asn1Data",
",",
"&",
"cert",
")",
"\n",
... | // ParseCertificate parses a single certificate from the given ASN.1 DER data. | [
"ParseCertificate",
"parses",
"a",
"single",
"certificate",
"from",
"the",
"given",
"ASN",
".",
"1",
"DER",
"data",
"."
] | 18fd8096dc8a3dcd43e9eccbdb4ef598900ae252 | https://github.com/tjfoc/gmsm/blob/18fd8096dc8a3dcd43e9eccbdb4ef598900ae252/sm2/x509.go#L1510-L1521 |
26,495 | tjfoc/gmsm | sm2/x509.go | ParseCertificates | func ParseCertificates(asn1Data []byte) ([]*Certificate, error) {
var v []*certificate
for len(asn1Data) > 0 {
cert := new(certificate)
var err error
asn1Data, err = asn1.Unmarshal(asn1Data, cert)
if err != nil {
return nil, err
}
v = append(v, cert)
}
ret := make([]*Certificate, len(v))
for i, ci... | go | func ParseCertificates(asn1Data []byte) ([]*Certificate, error) {
var v []*certificate
for len(asn1Data) > 0 {
cert := new(certificate)
var err error
asn1Data, err = asn1.Unmarshal(asn1Data, cert)
if err != nil {
return nil, err
}
v = append(v, cert)
}
ret := make([]*Certificate, len(v))
for i, ci... | [
"func",
"ParseCertificates",
"(",
"asn1Data",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"*",
"Certificate",
",",
"error",
")",
"{",
"var",
"v",
"[",
"]",
"*",
"certificate",
"\n\n",
"for",
"len",
"(",
"asn1Data",
")",
">",
"0",
"{",
"cert",
":=",
"new"... | // ParseCertificates parses one or more certificates from the given ASN.1 DER
// data. The certificates must be concatenated with no intermediate padding. | [
"ParseCertificates",
"parses",
"one",
"or",
"more",
"certificates",
"from",
"the",
"given",
"ASN",
".",
"1",
"DER",
"data",
".",
"The",
"certificates",
"must",
"be",
"concatenated",
"with",
"no",
"intermediate",
"padding",
"."
] | 18fd8096dc8a3dcd43e9eccbdb4ef598900ae252 | https://github.com/tjfoc/gmsm/blob/18fd8096dc8a3dcd43e9eccbdb4ef598900ae252/sm2/x509.go#L1525-L1548 |
26,496 | tjfoc/gmsm | sm2/x509.go | asn1BitLength | func asn1BitLength(bitString []byte) int {
bitLen := len(bitString) * 8
for i := range bitString {
b := bitString[len(bitString)-i-1]
for bit := uint(0); bit < 8; bit++ {
if (b>>bit)&1 == 1 {
return bitLen
}
bitLen--
}
}
return 0
} | go | func asn1BitLength(bitString []byte) int {
bitLen := len(bitString) * 8
for i := range bitString {
b := bitString[len(bitString)-i-1]
for bit := uint(0); bit < 8; bit++ {
if (b>>bit)&1 == 1 {
return bitLen
}
bitLen--
}
}
return 0
} | [
"func",
"asn1BitLength",
"(",
"bitString",
"[",
"]",
"byte",
")",
"int",
"{",
"bitLen",
":=",
"len",
"(",
"bitString",
")",
"*",
"8",
"\n\n",
"for",
"i",
":=",
"range",
"bitString",
"{",
"b",
":=",
"bitString",
"[",
"len",
"(",
"bitString",
")",
"-",... | // asn1BitLength returns the bit-length of bitString by considering the
// most-significant bit in a byte to be the "first" bit. This convention
// matches ASN.1, but differs from almost everything else. | [
"asn1BitLength",
"returns",
"the",
"bit",
"-",
"length",
"of",
"bitString",
"by",
"considering",
"the",
"most",
"-",
"significant",
"bit",
"in",
"a",
"byte",
"to",
"be",
"the",
"first",
"bit",
".",
"This",
"convention",
"matches",
"ASN",
".",
"1",
"but",
... | 18fd8096dc8a3dcd43e9eccbdb4ef598900ae252 | https://github.com/tjfoc/gmsm/blob/18fd8096dc8a3dcd43e9eccbdb4ef598900ae252/sm2/x509.go#L1560-L1575 |
26,497 | tjfoc/gmsm | sm2/x509.go | marshalSANs | func marshalSANs(dnsNames, emailAddresses []string, ipAddresses []net.IP) (derBytes []byte, err error) {
var rawValues []asn1.RawValue
for _, name := range dnsNames {
rawValues = append(rawValues, asn1.RawValue{Tag: 2, Class: 2, Bytes: []byte(name)})
}
for _, email := range emailAddresses {
rawValues = append(r... | go | func marshalSANs(dnsNames, emailAddresses []string, ipAddresses []net.IP) (derBytes []byte, err error) {
var rawValues []asn1.RawValue
for _, name := range dnsNames {
rawValues = append(rawValues, asn1.RawValue{Tag: 2, Class: 2, Bytes: []byte(name)})
}
for _, email := range emailAddresses {
rawValues = append(r... | [
"func",
"marshalSANs",
"(",
"dnsNames",
",",
"emailAddresses",
"[",
"]",
"string",
",",
"ipAddresses",
"[",
"]",
"net",
".",
"IP",
")",
"(",
"derBytes",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"var",
"rawValues",
"[",
"]",
"asn1",
".",
"RawV... | // marshalSANs marshals a list of addresses into a the contents of an X.509
// SubjectAlternativeName extension. | [
"marshalSANs",
"marshals",
"a",
"list",
"of",
"addresses",
"into",
"a",
"the",
"contents",
"of",
"an",
"X",
".",
"509",
"SubjectAlternativeName",
"extension",
"."
] | 18fd8096dc8a3dcd43e9eccbdb4ef598900ae252 | https://github.com/tjfoc/gmsm/blob/18fd8096dc8a3dcd43e9eccbdb4ef598900ae252/sm2/x509.go#L1608-L1625 |
26,498 | tjfoc/gmsm | sm2/x509.go | signingParamsForPublicKey | func signingParamsForPublicKey(pub interface{}, requestedSigAlgo SignatureAlgorithm) (hashFunc Hash, sigAlgo pkix.AlgorithmIdentifier, err error) {
var pubType PublicKeyAlgorithm
switch pub := pub.(type) {
case *rsa.PublicKey:
pubType = RSA
hashFunc = SHA256
sigAlgo.Algorithm = oidSignatureSHA256WithRSA
sig... | go | func signingParamsForPublicKey(pub interface{}, requestedSigAlgo SignatureAlgorithm) (hashFunc Hash, sigAlgo pkix.AlgorithmIdentifier, err error) {
var pubType PublicKeyAlgorithm
switch pub := pub.(type) {
case *rsa.PublicKey:
pubType = RSA
hashFunc = SHA256
sigAlgo.Algorithm = oidSignatureSHA256WithRSA
sig... | [
"func",
"signingParamsForPublicKey",
"(",
"pub",
"interface",
"{",
"}",
",",
"requestedSigAlgo",
"SignatureAlgorithm",
")",
"(",
"hashFunc",
"Hash",
",",
"sigAlgo",
"pkix",
".",
"AlgorithmIdentifier",
",",
"err",
"error",
")",
"{",
"var",
"pubType",
"PublicKeyAlgo... | // signingParamsForPublicKey returns the parameters to use for signing with
// priv. If requestedSigAlgo is not zero then it overrides the default
// signature algorithm. | [
"signingParamsForPublicKey",
"returns",
"the",
"parameters",
"to",
"use",
"for",
"signing",
"with",
"priv",
".",
"If",
"requestedSigAlgo",
"is",
"not",
"zero",
"then",
"it",
"overrides",
"the",
"default",
"signature",
"algorithm",
"."
] | 18fd8096dc8a3dcd43e9eccbdb4ef598900ae252 | https://github.com/tjfoc/gmsm/blob/18fd8096dc8a3dcd43e9eccbdb4ef598900ae252/sm2/x509.go#L1814-L1887 |
26,499 | tjfoc/gmsm | sm2/x509.go | ParseCRL | func ParseCRL(crlBytes []byte) (*pkix.CertificateList, error) {
if bytes.HasPrefix(crlBytes, pemCRLPrefix) {
block, _ := pem.Decode(crlBytes)
if block != nil && block.Type == pemType {
crlBytes = block.Bytes
}
}
return ParseDERCRL(crlBytes)
} | go | func ParseCRL(crlBytes []byte) (*pkix.CertificateList, error) {
if bytes.HasPrefix(crlBytes, pemCRLPrefix) {
block, _ := pem.Decode(crlBytes)
if block != nil && block.Type == pemType {
crlBytes = block.Bytes
}
}
return ParseDERCRL(crlBytes)
} | [
"func",
"ParseCRL",
"(",
"crlBytes",
"[",
"]",
"byte",
")",
"(",
"*",
"pkix",
".",
"CertificateList",
",",
"error",
")",
"{",
"if",
"bytes",
".",
"HasPrefix",
"(",
"crlBytes",
",",
"pemCRLPrefix",
")",
"{",
"block",
",",
"_",
":=",
"pem",
".",
"Decod... | // ParseCRL parses a CRL from the given bytes. It's often the case that PEM
// encoded CRLs will appear where they should be DER encoded, so this function
// will transparently handle PEM encoding as long as there isn't any leading
// garbage. | [
"ParseCRL",
"parses",
"a",
"CRL",
"from",
"the",
"given",
"bytes",
".",
"It",
"s",
"often",
"the",
"case",
"that",
"PEM",
"encoded",
"CRLs",
"will",
"appear",
"where",
"they",
"should",
"be",
"DER",
"encoded",
"so",
"this",
"function",
"will",
"transparent... | 18fd8096dc8a3dcd43e9eccbdb4ef598900ae252 | https://github.com/tjfoc/gmsm/blob/18fd8096dc8a3dcd43e9eccbdb4ef598900ae252/sm2/x509.go#L2003-L2011 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.