Go Programming with Jupyter interaction

Source: Internet
Author: User
Tags comparison table jupyter jupyter notebook
! [] (Https://raw.githubusercontent.com/studygolang/gctt-images/master/jupyte/go_jupyter_1.jpeg) In recent years, the go language has become very popular. I'm a big fan of Python, and my first amateur project three years ago was also implemented in Python. And now I'm starting with the go language instead of Python, because the go language makes my coding more efficient, whether it's a hobby small project or a big project in the company. At the same time, Python is becoming more popular as machine learning and data science become more and more important. There are a number of reasons why Python is preferred in machine learning, one reason being that Python is designed for interactive code writing and computation. Another important reason is that there is a good interactive programming tool in Python: [Jupyter Notebook] (http://jupyter.org/). Although I now use the Go language in many projects that used to be python, I still need to use Python for machine learning research and data analysis. The ability of interactive programming and Jupyter Notebook in Python is still very appealing to me. I want to have a really useful Jupyter environment for the Go language and a Jupyter kernel that verifies the correctness of the go language. But there are no such projects, and some similar projects have been terminated. While some of these are more prevalent, they are not suitable for practical use because they do not support type safety, code cancellation, code completion, checking, or displaying non-textual content. So I decided to develop a new environment to run the Go language interactively on Jupyter Notebook from the beginning. Here, I'll show you the software I've built, and the new way to write and execute Go interactively like Python. [] (Https://raw.githubusercontent.com/studygolang/gctt-images/master/jupyte/go_jupyter_2.gif) # # GitHub On the project homepage I'll introduce you to Yunabe/lgo, a Jupyter Notebook kernel for the Go language and an interactive interpreter. Please see the warehouse below for details. [Yunabe/lgo] (Https://github.com/yunabe/lgo) # # in the browser try the following link is the Go language of the Jupyter line running environment:[Mybinder.org] (HTTPS://MYBINDER.ORG/V2/GH/YUNABE/LGO-BINDER/MASTER?FILEPATH=BASICS.IPYNB) Thanks to binder [(mybinder.org)] (https:// mybinder.org/), you can use the temporary Docker container on the binder on your browser to try the Go language's Jupyter Environment (LGO). Open the temporary Jupyter Notebook from the button above and enjoy interactive Go programming! # # Main Features * write and run Go programs like Python. * Jupyter Notebook function * Fully complies with the Go Language specification while 100% compatible with the Go language compiler. * with Jupyter Notebook the same code completion, check and code formatting. * Display images, html,javascript,svg and so on. * Interactive interpreter on the console * fully supports goroutine and channel! [] (HTTPS://RAW.GITHUBUSERCONTENT.COM/STUDYGOLANG/GCTT-IMAGES/MASTER/JUPYTE/GO_JUPYTER_3.JPEG)! [] (HTTPS://RAW.GITHUBUSERCONTENT.COM/STUDYGOLANG/GCTT-IMAGES/MASTER/JUPYTE/GO_JUPYTER_4.JPEG)! [] (HTTPS://RAW.GITHUBUSERCONTENT.COM/STUDYGOLANG/GCTT-IMAGES/MASTER/JUPYTE/GO_JUPYTER_5.JPEG)! [] (Https://raw.githubusercontent.com/studygolang/gctt-images/master/jupyte/go_jupyter_6.jpeg) # # There are two ways to install the Go language The Jupyter environment is installed on your computer. * [using a pre-built Docker image] (https://github.com/yunabe/lgo#quick-start-with-docker) * [Source installation (currently supported only for Linux)] (https:// Github.com/yunabe/lgo#install) If you want to be quick on your computerTry the jupyter environment in the go language, first try the Docker version. If you use Linux and want to integrate the Jupyter environment with the GO environment into your computer, you can choose to install the source code. Because of the use of ['-buildmode = Shared ' for regression] (https://github.com/golang/go/issues/24034), Lgo code runs slowly in go1.10. Before go1.10 fix the bug, use go1.9 to try the Lgo. Currently LGO works perfectly in go1.9 and go1.8. For Windows and Mac users, use the Docker version because LGO does not support Windows and Macs. You can run Lgo on Windows or on your Mac with Docker. # # Use execute ' jupyter notebook ' command as usual to start Jupyter notebook. When you create a new note, choose ' Go ' from the Lgo menu. Once you have created a new note, you can write and execute the program interactively like Python. In Lgo, you can display related documents for variables, functions, and types by moving the cursor to an identifier and pressing ' Shift-tab '. You can complete the code by pressing ' Tab '. If you want to display non-textual data, you can refer to [This example] (http://nbviewer.jupyter.org/github/yunabe/lgo/blob/master/examples/basics.ipynb#Display ) to use the ' Datadisplayer ' type. [] (Https://raw.githubusercontent.com/studygolang/gctt-images/master/jupyte/go_jupyter_7.jpeg) # # # As with the console's interpreter environment, you can also use LGO as you would with an interpreter. After the installation is complete, run the instruction ' Jupyter console--kernel lgo '. Of course, in this mode you can also use ' Tab ' or ' ctrl-i ' to achieve the completion of the code. ' Pyter console--kernelin [1]: A, B: = 3, 4In [2]: Func sum (x, y int) int {: return x + y :}in [3]: Import "FMT" in [4]: FMT. Sprintf ("sum (%d,%d) =%d", a, B, sum (A, B)) sum (3, 4) = 7 "# # compared to the existing frame for those who understand other existing Golang Jupyter kernels, here is a comparison table with the competitor. You can read [' Readne '. MD ' in this section] (https://github.com/yunabe/lgo#comparisons-with-similar-projects) for more details. [] (Https://raw.githubusercontent.com/studygolang/gctt-images/master/jupyte/go_jupyter_8.jpeg) # # Learn more if you want to know more, Please browse [homepage of this Project] (HTTPS://GITHUB.COM/YUNABE/LGO) and read the introduction in ' Readme.md '. In addition, you can learn more about Go in these [sample notes] (HTTPS://NBVIEWER.JUPYTER.ORG/GITHUB/YUNABE/LGO/BLOB/MASTER/EXAMPLES/BASICS.IPYNB) The real purpose of the jupyter environment of the language. Enjoy the interactive programming of the Go language!

via:https://medium.com/@yunabe/interactive-go-programming-with-jupyter-93fbf089aff1

Author: Yu Watanabe Translator: 7Ethan proofreading: polaris1119

This article by GCTT original compilation, go language Chinese network honor launches

This article was originally translated by GCTT and the Go Language Chinese network. Also want to join the ranks of translators, for open source to do some of their own contribution? Welcome to join Gctt!
Translation work and translations are published only for the purpose of learning and communication, translation work in accordance with the provisions of the CC-BY-NC-SA agreement, if our work has violated your interests, please contact us promptly.
Welcome to the CC-BY-NC-SA agreement, please mark and keep the original/translation link and author/translator information in the text.
The article only represents the author's knowledge and views, if there are different points of view, please line up downstairs to spit groove

451 Reads
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.