5 <title>CodeMirror: Go mode</title>
6 <link rel="stylesheet" href="../../lib/codemirror.css">
7 <link rel="stylesheet" href="../../theme/elegant.css">
8 <script src="../../lib/codemirror.js"></script>
9 <script src="../../addon/edit/matchbrackets.js"></script>
10 <script src="go.js"></script>
11 <link rel="stylesheet" href="../../doc/docs.css">
12 <style>.CodeMirror {border:1px solid #999; background:#ffc}</style>
15 <h1>CodeMirror: Go mode</h1>
17 <form><textarea id="code" name="code">
19 // Taken from the Go specification.
20 // Copyright © The Go Authors.
26 // Send the sequence 2, 3, 4, ... to channel 'ch'.
27 func generate(ch chan<- int) {
29 ch <- i // Send 'i' to channel 'ch'
33 // Copy the values from channel 'src' to channel 'dst',
34 // removing those divisible by 'prime'.
35 func filter(src <-chan int, dst chan<- int, prime int) {
36 for i := range src { // Loop over values received from 'src'.
38 dst <- i // Send 'i' to channel 'dst'.
43 // The prime sieve: Daisy-chain filter processes together.
45 ch := make(chan int) // Create a new channel.
46 go generate(ch) // Start generate() as a subprocess.
49 fmt.Print(prime, "\n")
51 go filter(ch, ch1, prime)
62 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
72 <p><strong>MIME type:</strong> <code>text/x-go</code></p>