𝔖 Scriptorium
✦   LIBER   ✦

📁

Go Crazy: A Fun Projects-based Approach to Golang Programming

✍ Scribed by Nicolas Modrzyk


Publisher
Apress
Year
2023
Tongue
English
Leaves
376
Category
Library

⬇  Acquire This Volume

No coin nor oath required. For personal study only.

✦ Synopsis


Go beyond the basics of Go and build complete applications using open-source libraries or the Go programming language by Google. This book will take you deep into the memory lane of the Go language with crunchy details straight from outer space.

The applications in this book include the framework for a 2D Go-based game, an image random generator Rest API, financial time series handling for trading, a Kubernetes operator, a Blockchain coding and more. You'll also get refreshers on Go constructs and useful code tricks to build performant projects, and develop an HTTP based cloud ready image generator.

Each chapter will be organized in the following format: what the particular application looks like; requirements and user stories of our example program; an introduction to the Go libraries or frameworks used; and the actual implementation of the example program, including common pitfalls and their solutions.

Go Crazy will open your eyes to a new world of practical applications for Go. After reading the book, you will be able to apply your Golang knowledge to build your own crazy projects. Free source code will be available on this book's Apress GitHub page.

What You'll Learn

  • Compile and inline other programming languages, including GPU coding.
  • Handle Kubernetes clusters via your own operator
  • Write Go to code against Ethereum based block chains.
  • Write intelligent bot code to get you rich and famous.

Who This Book Is For

Go programmers both experienced and novice.

✦ Table of Contents


Table of Contents
About the Author
About the Technical Reviewer
Acknowledgments
Introduction
Chapter 1: Go to the Basics
First Steps
Run and Debug Your First Go Program
A Short Note on Debugging with GoLand
Before Talking to OpenAI: Reviewing Concepts
Read from Input
Reading from a File
Custom Data: Go Structs
Writing and Reading Structs from Files
Reading a Struct from a File
Slicing Program Arguments
Using a Custom Library to Load the API Key
Asynchronous Code: Go Routines
Asynchronous Code: Go Routines and Channels
Using Go Contexts
Putting Things Together Into a ChatGPT Client
Getting an API Key
First Request
Customize the ChatGPT Request
Create a Loop Prompt
Streaming the Response
Query and Use a Custom Model
Summary
Chapter 2: Write a Tested HTTP Image Generator API
Pour Me Some Gin!
Working with Queues
Image Generators
Image Generator in a Gin
Quick Gin Tonic and Templates
Use a Synchronized Map
Testing the API
Simple Go and Gin Testing
Testing the Image Generator
Summary
Chapter 3: Writing the Basics for a 2D Game in Go
Some Tile Set History
Library Setup: Raylib
Game Setup
Quick Game Generation with ChatGPT
Display the Date in Real Time
Hangman Game
The Moyashi Game
The Basic Game Loop
Loading Textures
Adding a Player Texture
Using Key Inputs
Doing the Game Music
Game Camera
Animate Sprites
Animation for an Idle Moyashi
Loading the World Map
Loading the Full World Map
Full Map and Full Screen
Summary
Chapter 4: Trend Follower for Blockchain Trading
Go Crazy or Go Home
Why Trade in the Financial Markets?
The Origins of Money
The Financial Economy vs. the Real Economy
Market Efficiency
Why Automate Trading?
The Secret Sauce
Charts
Data
News and Content
Strategy
Backtesting
Real-Time Trading
The Recipe
Clear Objectives and a Structured Approach
Macroeconomic Tendencies
Timeframe
Risk Management
Testing and Debugging
Performance Evaluation
Scalability and Maintainability
Compliance and Regulation
Security
Building Confidence
Refining Trading Strategies
Utensils in the Kitchen
Modern Trading Tool
Brokers
Cloud Infrastructure
Cooking
Backtesting
Data
Indicators
Levels
Simple Moving Averages
Exponential Moving Averages
Relative Strength Index
Additional Notes
Enhancing Discipline and Consistency
Why So Many Features?
Sample Code
Exchange Connectivity (Listing 4-1)
Building Indicators (Listing 4-2)
The Strategy
Run the Bot
Performance Evaluation
Stats
PnL
PnL in Backtesting
PnL in Real-Time Testing
Hit Rate
Hit Rate in Trading Strategy Evaluation
The Potential Drawbacks of an Excessively High Hit Rate
Sharpe Ratio
Risk-Adjusted Performance
Benchmarking and Comparison
Portfolio Diversification
Potential Pitfalls
MAR Ratio
Emphasis on Drawdown Risk
Risk-Adjusted Performance
Comparison of Strategies
Suitability for Trend-Following Strategies
Potential Pitfalls
Success or Failure and Why
Benchmark Comparison
Timeframe
Risk Management and Continuous Improvement
Potential Pitfalls
Example of Backtesting Multiple Strategies
A Taste Before Serving the Meal
Ensuring System Stability
Hidden Difficulties
Forensic Analysis
Potential Pitfalls
Dinner Is Served
Skin in the Game
Fear vs. Greed
Which Products to Trade
Machine Learning
Dessert!
The Exponential Age Is Here
The Proverbial “Cherry on Top”
Appendix
Finance Jargon
Glossary
One-liner
Extra Indicators of Interest
Tom Demark’s Indicators
Extra Statistics
Side Notes on Geth
Ethereum’s GoLang Implementation: Geth
GoLang’s Advantages for Blockchain Development
References
Chapter 5: Writing a Kubernetes Operator to Run EVM-Compatible Blockchains
Setting Up Kubernetes on Your Machine
Resources Overview
Let’s Run a Pod
Demystifying Kubernetes Operators
Custom Resource Definition
Controller
Bootstrapping the Project with Operator-SDK
Creating an API
Generating the Manifests
Configuring the Makefile
Implementing the Operator Reconciliation Logic
Using the Kubernetes Go SDK
Interacting with the JSON-RPC API
Using Port-Forward
Parameterizing Resources and Ports
Implementing the Update Logic
Implementing Health Checks
Creating a Minimal Go HTTP Server
Performing a net_peerCount Health Check
Configuring the Readiness Probe
Summary
Chapter 6: Go Beyond: Connecting to C for a Performance Boost
C is for Change
Calling C
Calling C Code Located in a C File
C Code Calling Go Code
Passing Parameters
Using a Header File
Using a C Struct from Go
Matisse, ImageMagick, and Sepia
ImageMagick on OSX
ImageMagick on Linux
ImageMagick on Raspberry Pi
GPU Coding on OSX
Basics: Adding Values from Two Arrays
Back to the Plot
Generic GPU Processing Go Code
Opens ETHUSD Hourlies Quotes: Moving Average
Slightly Better Moving Average on the GPU
Normalized Set
Pearson Coefficient Moving Factor
Sepia Gopher
Extreme Calling OpenCV/C++ from Go
Summary
Chapter 7: Alef from Plan 9
Plan 9 from Bell Labs
The Network Is the Computer
The Alef Language
Hello Tuple!
Channels and Processes
Proc and Task
Have Fun with Plan 9
Index


📜 SIMILAR VOLUMES


Mastering Arduino: A Project-Based Appro
✍ Hoffman, Jon 📂 Library 📅 2018 🏛 Packt Publishing Ltd 🌐 English

Mastering Arduino is a practical, no-nonsense guide teaching you the electronics and programming skills that you need to create advanced Arduino projects. It is packed full of real-world projects leading up to the final project where you will build and control a basic robot.</div>

Mastering Arduino: a project-based appro
✍ Hoffman, Jon 📂 Library 📅 2018 🏛 Packt Publishing Limited; Packt Publishing Ltd 🌐 English

<p><b>Mastering Arduino is a practical, no-nonsense guide that will teach you the electronics and programming skills that you need to create advanced Arduino projects.</b><p><b>Key Features</b><li>Covers enough electronics and code for users at any level<li>Includes complete circuit diagrams for all

Project and Program Management: A Compet
✍ Mitchell L. Springer 📂 Library 📅 2013 🏛 Purdue University Press 🌐 English

<p></p><div><p class="MsoNormal" style="line-height:normal">Choosing the right people to carry out a project is essential to its success. When multiple projects are combined into a complex program, the “human aspect” becomes even more important. This book is the first to truly balance a complete acc

From Ruby to Golang : A Ruby Programmer'
✍ Joel Bryan Juliano 📂 Library 📅 2019 🏛 leanpub.com 🌐 English

By teaching familiar implementations found in Ruby, you will see the correlation between the two languages, establishing familiar concepts to give you enough knowledge to be comfortable with Go and to start programming with it. Imagine that you like to learn a new programming language, and you st