توضیحاتی در مورد کتاب :
با زبان برنامه نویسی Go ابزارهای خط فرمان سریع، قابل اعتماد و چند پلتفرمی خود را بنویسید. Go ممکن است سریعترین و شاید سرگرمکنندهترین راه برای خودکار کردن وظایف، تجزیه و تحلیل دادهها، تجزیه گزارشها، صحبت با سرویسهای شبکه، یا رفع نیازهای دیگر سیستم باشد. انواع ابزارهای خط فرمان را ایجاد کنید که با فایلها کار میکنند، به سرویسها متصل میشوند و فرآیندهای خارجی را مدیریت میکنند، همگی با استفاده از تستها و معیارها برای اطمینان از اینکه برنامههای شما سریع و صحیح هستند.
Go یک زبان برنامه نویسی مدرن است که قابلیت اطمینان زبان های کامپایل شده را با سهولت استفاده و انعطاف پذیری زبان های تایپ پویا ترکیب می کند. با Go، میتوانید ابزارهای خط فرمان چند پلتفرمی را توسعه دهید که سریع و قابل اعتماد هستند. با استفاده از کتابخانه استاندارد غنی Go، پشتیبانی داخلی آن از همزمانی و نحو بیانی آن، از طریق مثالهای عملی برای توسعه ابزارهای زیبا و کارآمد کار کنید. از قابلیتهای تست یکپارچه Go برای آزمایش خودکار ابزارهای خود استفاده کنید، و مطمئن شوید که آنها به طور قابل اعتماد کار میکنند، حتی در بازآفرینی کد.
ابزارهای CLI را توسعه دهید که با استفاده از الگوهای ورودی/خروجی رایج، از جمله متغیرهای محیطی و پرچمها، با کاربران شما تعامل داشته باشند. فایلها را برای خواندن یا ماندگاری دادهها مدیریت کنید و مسیرها را بهطور مداوم در سناریوهای چند پلتفرمی دستکاری کنید. فرآیندها را کنترل کنید و سیگنالها را مدیریت کنید و از رویکرد مبتنی بر معیار و اصول اولیه همزمانی Go برای ایجاد ابزارهایی استفاده کنید که عملکرد خوبی دارند. از کتابخانههای خارجی قدرتمند مانند Cobra برای ایجاد ابزارهای مدرن و انعطافپذیر که فرمانهای فرعی را مدیریت میکنند، و توسعه ابزارهایی که با پایگاههای داده، APIها و سرویسهای شبکه تعامل دارند، استفاده کنید. در نهایت، با مقابله با چالشهای اضافی در پایان هر فصل، از آنچه آموختید استفاده کنید.
فهرست مطالب :
Contents & Extracts
Foreword
Acknowledgments
Preface
What’s in This Book
How to Use This Book
About the Example Code
Go Modules
Online Resources
Your First Command-Line Program in Go
Building the Basic Word Counter
Testing the Basic Word Counter
Adding Command-Line Flags
Compiling Your Tool for Different Platforms
Exercises
Wrapping Up
Interacting with Your Users
Organizing Your Code
Defining the To-Do API
Creating the Initial To-Do Command-Line Tool
Testing the Initial CLI Implementation
Handling Multiple Command-Line Options
Display Command-Line Tool Usage
Improving the List Output Format
Increasing Flexibility with Environment Variables
Capturing Input from STDIN
Exercises
Wrapping Up
Working with Files in Go
Creating a Basic Markdown Preview Tool
Writing Tests for the Markdown Preview Tool
Adding Temporary Files to the Markdown Preview Tool
Using Interfaces to Automate Tests
Adding an Auto-Preview Feature
Cleaning Up Temporary Files
Improving the Markdown Preview Tool with Templates
Exercises
Wrapping Up
Navigating the File System
Developing a File System Crawler
Testing with Table-Driven Testing
Deleting Matched Files
Testing with the Help of Test Helpers
Logging Deleted Files
Archiving Files
Exercises
Wrapping Up
Improving the Performance of Your CLI Tools
Developing the Initial Version of colStats
Writing Tests for colStats
Benchmarking Your Tool
Profiling Your Tool
Reducing Memory Allocation
Tracing Your Tool
Improving the colStats Tool to Process Files Concurrently
Reduce Scheduling Contention
Exercises
Wrapping Up
Controlling Processes
Executing External Programs
Handling Errors
Writing Tests for Goci
Defining a Pipeline
Adding Another Step to the Pipeline
Handling Output from External Programs
Running Commands with Contexts
Integration Tests with a Local Git Server
Testing Commands with Mock Resources
Handling Signals
Exercises
Wrapping Up
Using the Cobra CLI Framework
Starting Your Cobra Application
Navigating Your New Cobra Application
Adding the First Subcommand to Your Application
Starting the Scan Package
Creating the Subcommands to Manage Hosts
Testing the Manage Hosts Subcommands
Adding the Port Scanning Functionality
Using Viper for Configuration Management
Generating Command Completion and Documentation
Exercises
Wrapping Up
Talking to REST APIs
Developing a REST API Server
Testing the REST API Server
Completing the REST API Server
Developing the Initial Client for the REST API
Testing the Client Without Connecting to the API
Viewing a Single Item
Adding an Item
Testing HTTP Requests Locally
Completing and Deleting Items
Executing Integration Tests
Exercises
Wrapping Up
Developing Interactive Terminal Tools
Initializing the Pomodoro Application
Storing Data with the Repository Pattern
Testing the Pomodoro Functionality
Building the Interface Widgets
Organizing the Interface’s Layout
Building the Interactive Interface
Initializing the CLI with Cobra
Exercises
Wrapping Up
Persisting Data in a SQL Database
Getting Started with SQLite
Go, SQL, and SQLite
Persisting Data in the Database
Testing the Repository with SQLite
Updating the Application to Use the SQLite Repository
Displaying a Summary to the Users
Exercises
Wrapping Up
Distributing Your Tool
Starting the Notify Package
Including OS-Specific Data
Including OS-Specific Files in the Build
Testing the Notify Package
Conditionally Building Your Application
Cross-Compiling Your Application
Compiling Your Go Application for Containers
Distributing Your Application as Source Code
Exercises
Wrapping Up
توضیحاتی در مورد کتاب به زبان اصلی :
Write your own fast, reliable, and cross-platform command-line tools with the Go programming language. Go might be the fastest—and perhaps the most fun—way to automate tasks, analyze data, parse logs, talk to network services, or address other systems requirements. Create all kinds of command-line tools that work with files, connect to services, and manage external processes, all while using tests and benchmarks to ensure your programs are fast and correct.
Go is a modern programming language that combines the reliability of compiled languages with the ease of use and flexibility of dynamic typed languages. With Go, you can develop cross-platform command-line tools that are fast and reliable. Work through practical examples to develop elegant and efficient tools by applying Go’s rich standard library, its built-in support for concurrency, and its expressive syntax. Use Go’s integrated testing capabilities to automatically test your tools, ensuring they work reliably, even across code refactoring.
Develop CLI tools that interact with your users by using common input/output patterns, including environment variables and flags. Handle files to read or persist data, and manipulate paths consistently in cross-platform scenarios. Control processes and handle signals, and use a benchmark-driven approach and Go’s concurrency primitives to create tools that perform well. Use powerful external libraries such as Cobra to create modern and flexible tools that handle subcommands, and develop tools that interact with databases, APIs, and network services. Finally, leverage what you learned by tackling additional challenges at the end of each chapter.