Skip to content

Commit

Permalink
Add Google Colab code
Browse files Browse the repository at this point in the history
  • Loading branch information
sualeh committed May 7, 2024
1 parent 2effab0 commit 1183ff5
Showing 1 changed file with 98 additions and 11 deletions.
109 changes: 98 additions & 11 deletions Notebooks/4_go_encoding.ipynb
Original file line number Diff line number Diff line change
@@ -1,5 +1,66 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"----------\n",
"\n",
"## Google Colab\n",
"\n",
"You can run this notebook in Google Colab. The cell below should be run only once, and then followed by a change of runtime to `Go (gonb)`. Refresh the browser before running any subsequent code. If you are not running the notebook in Google Colab, skip this section."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"vscode": {
"languageId": "polyglot-notebook"
}
},
"outputs": [],
"source": [
"#@title Prepare Google Colab for Go Kernel\n",
"\n",
"# Install Go and goimports.\n",
"!echo -n \"Installing go ...\"\n",
"!mkdir -p cache\n",
"!wget -q -O cache/go.tar.gz 'https://go.dev/dl/go1.22.2.linux-amd64.tar.gz'\n",
"!tar xzf cache/go.tar.gz\n",
"%env GOROOT=/content/go\n",
"!ln -sf \"/content/go/bin/go\" /usr/bin/go\n",
"!echo \" done.\"\n",
"!go version\n",
"\n",
"# Install gonb, goimports, gopls.\n",
"!echo -n \"Installing gonb ...\"\n",
"!go install github.com/janpfeifer/gonb@latest >& /tmp/output || cat /tmp/output\n",
"!echo \" done.\"\n",
"!ln -sf /root/go/bin/gonb /usr/bin/gonb\n",
"\n",
"!echo -n \"Installing goimports ...\"\n",
"!go install golang.org/x/tools/cmd/goimports@latest >& /tmp/output || cat /tmp/output\n",
"!echo \" done.\"\n",
"!ln -sf /root/go/bin/goimports /usr/bin/goimports\n",
"\n",
"!echo -n \"Installing gopls ...\"\n",
"!go install golang.org/x/tools/gopls@latest >& /tmp/output || cat /tmp/output\n",
"!echo \" done.\"\n",
"!ln -sf /root/go/bin/gopls /usr/bin/gopls\n",
"\n",
"# Install gonb kernel configuration.\n",
"!gonb --install --logtostderr\n",
"!echo \"Done!\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"----------"
]
},
{
"cell_type": "markdown",
"metadata": {
Expand All @@ -24,7 +85,10 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "yNU6pAmXRNRx"
"id": "yNU6pAmXRNRx",
"vscode": {
"languageId": "polyglot-notebook"
}
},
"outputs": [],
"source": [
Expand Down Expand Up @@ -57,7 +121,10 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "6uMstf9XRNRy"
"id": "6uMstf9XRNRy",
"vscode": {
"languageId": "polyglot-notebook"
}
},
"outputs": [],
"source": [
Expand Down Expand Up @@ -85,7 +152,10 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "F5IkwmzRRNRy"
"id": "F5IkwmzRRNRy",
"vscode": {
"languageId": "polyglot-notebook"
}
},
"outputs": [],
"source": [
Expand All @@ -111,7 +181,10 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "YfuallDiRNRy"
"id": "YfuallDiRNRy",
"vscode": {
"languageId": "polyglot-notebook"
}
},
"outputs": [],
"source": [
Expand All @@ -135,7 +208,10 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "d5y1y6cbRNRz"
"id": "d5y1y6cbRNRz",
"vscode": {
"languageId": "polyglot-notebook"
}
},
"outputs": [],
"source": [
Expand All @@ -157,10 +233,13 @@
}
],
"metadata": {
"colab": {
"provenance": []
},
"kernelspec": {
"display_name": "base",
"language": "python",
"name": "python3"
"display_name": ".NET (C#)",
"language": "C#",
"name": ".net-csharp"
},
"language_info": {
"codemirror_mode": {
Expand All @@ -174,10 +253,18 @@
"pygments_lexer": "ipython3",
"version": "3.11.5"
},
"colab": {
"provenance": []
"polyglot_notebook": {
"kernelInfo": {
"defaultKernelName": "csharp",
"items": [
{
"aliases": [],
"name": "csharp"
}
]
}
}
},
"nbformat": 4,
"nbformat_minor": 0
}
}

0 comments on commit 1183ff5

Please sign in to comment.