gophernotes/examples/Simple-Example.ipynb
2016-01-23 15:47:03 -06:00

164 lines
2.7 KiB
Plaintext

{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Imports"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
":import \"fmt\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Hello World"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"\u001b[31m\u001b[1m\"\u001b[0m\u001b[31mworld\u001b[0m\u001b[31m\u001b[1m\"\u001b[0m\n"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"world := \"world\""
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"\u001b[31m\u001b[1m\"\u001b[0m\u001b[31mhello world\u001b[0m\u001b[31m\u001b[1m\"\u001b[0m\n"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"fmt.Sprintf(\"hello %s\", world)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Channels"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Here is a simple example of a channel. "
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"(\u001b[32mchan string\u001b[0m)(\u001b[34m\u001b[1m0xc820018120\u001b[0m)\n"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"messages := make(chan string)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"go func() { messages <- \"ping\" }()"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"\u001b[31m\u001b[1m\"\u001b[0m\u001b[31mping\u001b[0m\u001b[31m\u001b[1m\"\u001b[0m\n"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"msg := <- messages"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Golang",
"language": "go",
"name": "gophernotes"
},
"language_info": {
"name": "go"
}
},
"nbformat": 4,
"nbformat_minor": 0
}