what's in this book

贡献者:deepfish 类别:英文 时间:2022-08-07 17:10:22 收藏数:30 评分:0
返回上页 举报此文章
请选择举报理由:




收藏到我的文章 改错字
What's in This Book
In Chapter 1, Your First Command-Line Program in Go, you'll take a quick tour through the
process of developing a command-line application with Go by building a word counter. You
will start with the basic implementation, add some features, and explore testing. You'll
also add command-line flags and build this application for different platforms.
In Chapter 2, Interacting with Your Users, you'll design and write a command-line tool to
manage lists of to-do items in accordance with common input/output standards by applying
different techniques. You'll take input from the standard input (STDIN) stream, parse
command-line parameters, and define flags for your tool using the flags package. You'll
use environment variables to increase the flexibility of your tools. In addition, you'll
display information and results back to the user through the standard output (STDOUT)
stream, and present errors using the standard error (STDERR) stream for proper error
handling. Finally, you'll explore Go interfaces by applying the io.Reader interface in
particular.
Next, in Chapter 3, Working with Files in Go, you'll develop a tool to preview Markdown
files using a web browser. You'll create and open files for reading and writing. You'll
apply techniques to handle paths consistently across different operating systems. You'll
use temporary files and apply the defer keyword to clean them up. You'll also make your
tool flexible by using file templates. Finally, you'll use Go interfaces to make your
code flexible, while writing and executing tests to ensure your code matches the
requirements.
In Chapter 4, Navigating the File System, you'll navigate through the file system and work
with directories and file properties. You'll develop a CLI application to find, delete,
and back up files according to different criteria. You'll perform common file system
operations such as copying, compressing, and deleting files. You'll also log information
to the screen or log files. Finally, you'll apply the concepts of table-driven testing
and test helpers to write flexible and meaningful test cases for your
application.
In Chapter 5, Improving the Performance of Your CLI Tools, you'll develop a command-line
tool that processes data from CSV files. Then you'll use Go's benchmarking, profiling,
and tracing tools to analyze its performance, find bottlenecks, and redesign your CLI to
improve its performance. You'll write and execute tests to ensure your application works
reliably across the refactoring. You'll also apply Go's concurrency primitives such as
goroutines and channels to ensure your application runs tasks concurrently in a safe
way.
Chapter 6, Controlling Processes, will allow you to expand your command-line applications'
capabilities by executing external tools. You'll execute, control, and capture their
output to develop a Continuous Integration tool for your Go programs. You'll explore
different ways to execute external programs with various options such as timeouts that
ensure your program doesn't run forever. You'll also handle operating system signals
correctly to allow your tool to gracefully shut down.
Next, in Chapter 7, Using the Cobra CLI Framework, you'll develop a network tool that
executes a TCP port scan on remote machines by applying the Cobra CLI framework. Cobra is
a popular framework that allows you to create flexible command-line tools that use
subcommands compatible with the POSIX standard. You'll use Cobra to generate the
boilerplate code for your application, allowing you to focus on its business
logic.
In Chapter 8, Talking to REST APIs, you'll improve your to-do application by making it
available through a representational state transfer (REST) API. Then you'll develop a
command-line client that interacts with this API using several HTTP methods. You'll parse
JSON data and fine-tune specific parameters of your requests such as headers and
timeouts. You'll also apply proper testing techniques that ensure your application works
reliably without overloading web servers unnecessarily.
In Chapter 9, Developing Interactive Terminal Tools, you'll build an interactive
command-line application that uses terminal widgets to interact with the user. You'll use
external packages to design and develop the interface. You'll also apply different Go
concurrency techniques to manage this application asynchronously.In Chapter 10,
Persisting Data in a SQL Database, you'll expand your interactive application by allowing
users to save its data into a SQL database. You'll use Go's standard library and external
packages to connect to standard databases by executing SQL operations. You'll query,
insert, and delete data from databases and use a local Sqlite3 database to persist data
for your tool. You'll make this data available to the user by summarizing its content
using the application interface.
And finally, in Chapter 11, Distributing Your Tool, you'll explore several techniques to
build your tool, including different build and cross-compilation options, allowing your
tool to run in multiple operating systems. You'll apply build tags to change the behavior
of your builds according to external conditions. You'll take a quick look at using CGO to
embed C code in your Go applications. Then you'll apply techniques to package and
distribute your application either as a Linux container or as source code via go
get.
This book doesn't cover the basic syntax of the Go programming language. You should be
familiar with declaring variables, types, custom types, flow control, and the general
structure of a Go program. If you're starting with Go, take a look at these books and
articles that do a great job explaining the language's syntax:
Learning Go [Jon21]
Go in Action [KKS15]
A Tour of Go[4]
Effective Go[5]
This book uses the Go standard library as much as possible. Go has a rich and diverse
standard library that includes packages that address most of the requirements for
creating command-line tools in general. By using the standard library, we benefit from
Go's compatibility across different versions making the code accessible to a larger
number of readers. cases, we'll use external packages when no equivalent functionality is
available but we generally prefer to use the standard library even if an external package
makes it easier to address a requirement. The notable exception to this rule is the Cobra
CLI framework that you'll use in Chapter 7, Using the Cobra CLI Framework, as this is a
popular framework used by many developers and companies to extend Go's capabilities to
manage command-line applications.
In each chapter, you'll typically develop a fully functional command-line tool. You'll
start with the basic functionality, write some tests, and then add more features. At the
end of each chapter, you'll find additional exercises to improve what you've learned in
the chapter and practice your skills further. And you're encouraged to add more features
on your own.
This book spends a fair amount of time on testing your code. In some cases, you'll see
that the test examples are more intricate than the code examples. This is done for two
significant reasons: as command-line tools become more critical to your infrastructure,
it's essential that you ensure they work correctly; and Go provides out-of-the-box
features to test and benchmark your code. You'll start by creating basic test functions.
Then you'll develop more advanced concepts such as table-driven testing and dependency
injection, culminating with mocking your own commands and artifacts for
testing.
Finally, feel free to read this book in any order. If you have a particular interest or if
one of the examples seems more appealing, feel free to jump around. Keep in mind that
some chapters build on skills presented in previous chapters. A cross-reference usually
points to where that concept was first discussed in the book so you can explore the topic
in more detail.
声明:以上文章均为用户自行添加,仅供打字交流使用,不代表本站观点,本站不承担任何法律责任,特此声明!如果有侵犯到您的权利,请及时联系我们删除。
文章热度:
文章难度:
文章质量:
说明:系统根据文章的热度、难度、质量自动认证,已认证的文章将参与打字排名!

本文打字排名TOP20