10 examples of 'golang rune' in Go

Every line of 'golang rune' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Go code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
57func (l Char) Unbox() interface{} {
58 return rune(l)
59}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

745func runeBytes(r rune) []byte {
746 buf := make([]byte, utf8.UTFMax)
747 n := utf8.EncodeRune(buf, r)
748 return buf[:n]
749}
28func ReadRune(input string) (theRune string, rest string, runeWidth int) {
29 prop, size := width.LookupString(input)
30 rest = input[size:]
31 theRune = input[:size]
32 switch prop.Kind() {
33 case width.EastAsianFullwidth, width.EastAsianHalfwidth, width.EastAsianWide:
34 runeWidth = 2
35 default:
36 runeWidth = 1
37 }
38 return
39}
304func (c *Caret) ReadRune() (r rune, size int, err error) {
305 c.calculatePLBK()
306 for {
307 if c.k < c.f.boxes[c.b].j {
308 r, size, c.b, c.k = c.f.readRune(c.b, c.k)
309 c.pos += int32(size)
310 // A Caret can't be placed at the end of a Paragraph, unless it is
311 // the final Paragraph. A simple way to enforce this is to lean
312 // forwards.
313 c.leanForwards()
314 return r, size, nil
315 }
316 if c.leanForwards() == leanFailedEOF {
317 return 0, 0, io.EOF
318 }
319 }
320}
319func runeAt(s string, byteIndex int) rune {
320 for _, r := range s[byteIndex:] {
321 return r
322 }
323
324 return rune(0xfffd)
325}
253func (g *GraphQLCommand) RunE(c *cobra.Command, args []string) error {
254 if err := g.checkValid(); err != nil {
255 return err
256 }
257 // just run parent command, as the real implementation
258 // of run is defined by root query
259 if p := g.FieldCommand.Command.Parent(); p != nil && p.RunE != nil {
260 return p.RunE(c, args)
261 }
262 return nil
263}
176func (m *MultibarWidget) RuneString() string {
177 return string(m.runes)
178}
330func (r *readRune) ReadRune() (rr rune, size int, err error) {
331 if r.peekRune >= 0 {
332 rr = r.peekRune
333 r.peekRune = ^r.peekRune
334 size = utf8.RuneLen(rr)
335 return
336 }
337 r.buf[0], err = r.readByte()
338 if err != nil {
339 return
340 }
341 if r.buf[0] < utf8.RuneSelf { // fast check for common ASCII case
342 rr = rune(r.buf[0])
343 size = 1 // Known to be 1.
344 // Flip the bits of the rune so it's available to UnreadRune.
345 r.peekRune = ^rr
346 return
347 }
348 var n int
349 for n = 1; !utf8.FullRune(r.buf[:n]); n++ {
350 r.buf[n], err = r.readByte()
351 if err != nil {
352 if err == io.EOF {
353 err = nil
354 break
355 }
356 return
357 }
358 }
359 rr, size = utf8.DecodeRune(r.buf[:n])
360 if size < n { // an error, save the bytes for the next read
361 copy(r.pendBuf[r.pending:], r.buf[size:n])
362 r.pending += n - size
363 }
364 // Flip the bits of the rune so it's available to UnreadRune.
365 r.peekRune = ^rr
366 return
367}
1880func randUTF8RuneData(r randyData) rune {
1881 ru := r.Intn(62)
1882 if ru < 10 {
1883 return rune(ru + 48)
1884 } else if ru < 36 {
1885 return rune(ru + 55)
1886 }
1887 return rune(ru + 61)
1888}
356func (r *readRune) ReadRune() (rr rune, size int, err error) {
357 r.buf[0], err = r.readByte()
358 if err != nil {
359 return 0, 0, err
360 }
361 if r.buf[0] < utf8.RuneSelf { // fast check for common ASCII case
362 rr = rune(r.buf[0])
363 size = 1 // Known to be 1.
364 return
365 }
366 var n int
367 for n = 1; !utf8.FullRune(r.buf[0:n]); n++ {
368 r.buf[n], err = r.readByte()
369 if err != nil {
370 if err == io.EOF {
371 err = nil
372 break
373 }
374 return
375 }
376 }
377 rr, size = utf8.DecodeRune(r.buf[0:n])
378 if size < n { // an error
379 r.unread(r.buf[size:n])
380 }
381 return
382}

Related snippets