万本电子书0元读

万本电子书0元读

顶部广告

Learning Go Programming电子书

售       价:¥

1人正在读 | 0人评论 9.8

作       者:Vladimir Vivien

出  版  社:Packt Publishing

出版时间:2016-10-26

字       数:221.3万

所属分类: 进口书 > 外文原版书 > 电脑/网络

温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印

为你推荐

  • 读书简介
  • 目录
  • 累计评论(0条)
  • 读书简介
  • 目录
  • 累计评论(0条)
An insightful guide to learning the Go programming languageAbout This Book·Insightful coverage of Go programming syntax, constructs, and idioms to help you understand Go code effectively·Push your Go skills, with topics such as, data types, channels, concurrency, object-oriented Go, testing, and network programming·Each chapter provides working code samples that are designed to help reader quickly understand respective topicWho This Book Is ForIf you have prior exposure to programming and are interested in learning the Go programming language, this book is designed for you. It will quickly run you through the basics of programming to let you exploit a number of features offered by Go programming language.What You Will Learn·Install and configure the Go development environment to quickly get started with your first program.·Use the basic elements of the language including source code structure, variables, constants, and control flow primitives to quickly get started with Go·Gain practical insight into the use of Go's type system including basic and composite types such as maps, slices, and structs.·Use interface types and techniques such as embedding to create idiomatic object-oriented programs in Go.·Develop effective functions that are encapsulated in well-organized package structures with support for error handling and panic recovery.·Implement goroutine, channels, and other concurrency primitives to write highly-concurrent and safe Go code·Write tested and benchmarked code using Go's built test tools·Access OS resources by calling C libraries and interact with program environment at runtimeIn DetailThe Go programming language has firmly established itself as a favorite for building complex and scalable system applications. Go offers a direct and practical approach to programming that let programmers write correct and predictable code using concurrency idioms and a full-featured standard library.This is a step-by-step, practical guide full of real world examples to help you get started with Go in no time at all. We start off by understanding the fundamentals of Go, followed by a detailed description of the Go data types, program structures and Maps. After this, you learn how to use Go concurrency idioms to avoid pitfalls and create programs that are exact in expected behavior. Next, you will be familiarized with the tools and libraries that are available in Go for writing and exercising tests, benchmarking, and code coverage.Finally, you will be able to utilize some of the most important features of GO such as, Network Programming and OS integration to build efficient applications. All the concepts are explained in a crisp and concise manner and by the end of this book; you would be able to create highly efficient programs that you can deploy over cloud.Style and approachThe book is written to serve as a reader-friendly step-by-step guide to learning the Go programming language. Each topic is sequentially introduced to build on previous materials covered. Every concept is introduced with easy-to-follow code examples that focus on maximizing the understanding of the topic at hand.
目录展开

Learning Go Programming

Learning Go Programming

Credits

About the Author

About the Reviewers

www.PacktPub.com

Why subscribe?

Preface

What this book covers

What you need for this book

Who this book is for

Conventions

Reader feedback

Customer support

Downloading the example code

Downloading the color images of this book

Errata

Piracy

Questions

1. A First Step in Go

The Go programming language

Playing with Go

No IDE required

Installing Go

Source code examples

Your first Go program

Go in a nutshell

Functions

Packages

The workspace

Strongly typed

Composite types

The named type

Methods and objects

Interfaces

Concurrency and channels

Memory management and safety

Fast compilation

Testing and code coverage

Documentation

An extensive library

The Go Toolchain

Summary

2. Go Language Essentials

The Go source file

Optional semicolon

Multiple lines

Go identifiers

The blank identifier

Muting package imports

Muting unwanted function results

Built-in identifiers

Types

Values

Functions

Go variables

Variable declaration

The zero-value

Initialized declaration

Omitting variable types

Short variable declaration

Restrictions for short variable declaration

Variable scope and visibility

Variable declaration block

Go constants

Constant literals

Typed constants

Untyped constants

Assigning untyped constants

Constant declaration block

Constant enumeration

Overriding the default enumeration type

Using iota in expressions

Skipping enumerated values

Go operators

Arithmetic operators

The increment and decrement operators

Go assignment operators

Bitwise operators

Logical Operators

Comparison operators

Operator precedence

Summary

3. Go Control Flow

The if statement

The if statement initialization

Switch statements

Using expression switches

The fallthrough cases

Expressionless switches

Switch initializer

Type switches

The for statements

For condition

Infinite loop

The traditional for statement

The for range

The break, continue, and goto statements

The label identifier

The break statement

The continue statement

The goto statement

Summary

4. Data Types

Go types

Numeric types

Unsigned integer types

Signed integer types

Floating point types

Complex number types

Numeric literals

Boolean type

Rune and string types

The rune

The string

Interpreted and raw string literals

Pointers

The pointer type

The address operator

The new() function

Pointer indirection - accessing referenced values

Type declaration

Type conversion

Summary

5. Functions in Go

Go functions

Function declaration

The function type

Variadic parameters

Function result parameters

Named result parameters

Passing parameter values

Achieving pass-by-reference

Anonymous Functions and Closures

Invoking anonymous function literals

Closures

Higher-order functions

Error signaling and handling

Signaling errors

Error handling

The error type

Deferring function calls

Using defer

Function panic and recovery

Function panic

Function panic recovery

Summary

6. Go Packages and Programs

The Go package

Understanding the Go package

The workspace

Creating a workspace

The import path

Creating packages

Declaring the package

Multi-File packages

Naming packages

Use globally unique namespaces

Add context to path

Use short names

Building packages

Installing a package

Package visibility

Package member visibility

Importing package

Specifying package identifiers

The dot identifier

The blank identifier

Package initialization

Creating programs

Accessing program arguments

Building and installing programs

Remote packages

Summary

7. Composite Types

The array type

Array initialization

Declaring named array types

Using arrays

Array length and capacity

Array traversal

Array as parameters

The slice type

Slice initialization

Slice representation

Slicing

Slicing a slice

Slicing an array

Slice expressions with capacity

Making a slice

Using slices

Slices as parameters

Length and capacity

Appending to slices

Copying slices

Strings as slices

The map type

Map initialization

Making Maps

Using maps

Map traversal

Map functions

Maps as parameters

The struct type

Accessing struct fields

Struct initialization

Declaring named struct types

The anonymous field

Promoted fields

Structs as parameters

Field tags

Summary

8. Methods, Interfaces, and Objects

Go methods

Value and pointer receivers

Objects in Go

The struct as object

Object composition

Field and method promotion

The constructor function

The interface type

Implementing an interface

Subtyping with Go interfaces

Implementing multiple interfaces

Interface embedding

The empty interface type

Type assertion

Summary

9. Concurrency

Goroutines

The go statement

Goroutine scheduling

Channels

The Channel type

The send and receive operations

Unbuffered channel

Buffered channel

Unidirectional channels

Channel length and capacity

Closing a channel

Writing concurrent programs

Synchronization

Streaming data

Using for…range to receive data

Generator functions

Selecting from multiple channels

Channel timeout

The sync package

Synchronizing with mutex locks

Synchronizing access to composite values

Concurrency barriers with sync.WaitGroup

Detecting race conditions

Parallelism in Go

Summary

10. Data IO in Go

IO with readers and writers

The io.Reader interface

Chaining readers

The io.Writer interface

Working with the io package

Working with files

Creating and opening files

Function os.OpenFile

Files writing and reading

Standard input, output, and error

Formatted IO with fmt

Printing to io.Writer interfaces

Printing to standard output

Reading from io.Reader

Reading from standard input

Buffered IO

Buffered writers and readers

Scanning the buffer

In-memory IO

Encoding and decoding data

Binary encoding with gob

Encoding data as JSON

Controlling JSON mapping with struct tags

Custom encoding and decoding

Summary

11. Writing Networked Services

The net package

Addressing

The net.Conn Type

Dialing a connection

Listening for incoming connections

Accepting client connections

A TCP API server

Connecting to the TCP server with telnet

Connecting to the TCP server with Go

The HTTP package

The http.Client type

Configuring the client

Handling client requests and responses

A simple HTTP server

The default server

Routing requests with http.ServeMux

The default ServeMux

A JSON API server

Testing the API server with cURL

An API server client in Go

A JavaScript API server client

Summary

12. Code Testing

The Go test tool

Test file names

Test organization

Writing Go tests

The test functions

Running the tests

Filtering executed tests

Test logging

Reporting failure

Skipping tests

Table-driven tests

HTTP testing

Testing HTTP server code

Testing HTTP client code

Test coverage

The cover tool

Code benchmark

Running the benchmark

Skipping test functions

The benchmark report

Adjusting N

Comparative benchmarks

Summary

累计评论(0条) 0个书友正在讨论这本书 发表评论

发表评论

发表评论,分享你的想法吧!

买过这本书的人还买过

读了这本书的人还在读

回顶部