/
githubmirror
/
CS-Notes
Обзор
Документация
Войти
/
githubmirror
/
CS-Notes
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
docs/_style/prism-master/examples/prism-go.html
68 строк
944 B
CyC2018
use prism-tomorrow.css
19 дек 2018, 09:09
19 дек 2018, 09:09
e9e604e
Код
Авторство
О чём код?
<h2>Comments</h2> <pre><code>// This is a comment /* This is a comment on multiple lines */</code></pre> <h2>Numbers</h2> <pre><code>42 0600 0xBadFace 170141183460469231731687303715884105727 0. 72.40 072.40 2.71828 1.e+0 6.67428e-11 1E6 .25 .12345E+5 0i 011i 0.i 2.71828i 1.e+0i 6.67428e-11i 1E6i .25i .12345E+5i</code></pre> <h2>Runes and strings</h2> <pre><code>'\t' '\000' '\x07' '\u12e4' '\U00101234' `abc` `multi-line string` "Hello, world!" "multi-line string"</code></pre> <h2>Functions</h2> <pre><code>func(a, b int, z float64) bool { return a*b < int(z) }</code></pre> <h2>Full example</h2> <pre><code>package main import "fmt" func sum(a []int, c chan int) { sum := 0 for _, v := range a { sum += v } c <- sum // send sum to c } func main() { a := []int{7, 2, 8, -9, 4, 0} c := make(chan int) go sum(a[:len(a)/2], c) go sum(a[len(a)/2:], c) x, y := <-c, <-c // receive from c fmt.Println(x, y, x+y) } </code></pre>