高朗 is designed by computer science heavyweights for solving real-world problem.

高朗 is an optimization language it is used by Uber and Google for its mapping, Netflix for having streaming.

Dereferencing a pointer from another package

This example aims to demonstrate declaration of a pointer and accessing the value of the variable which the pointer points to.

Dynamic XML parser without 结构 in Go

xmlquery is an XPath query package for XML document, lets you extract data or evaluate from XML documents by an XPath expression. It is hosted on GitHub, along with additional documentation in the README.md file: //github.com/antchfx/xmlquery

Dynamic JSON parser without 结构 in 高朗

Gabs is a small utility for dealing with dynamic or unknown JSON structures in Go. It does not require you to know the structure of the payload (eg. create structs), and allows accessing fields by providing the path to them. It's pretty much just a helpful wrapper for navigating hierarchies of map[string]interface{} objects provided by the encoding/json package. It does nothing spectacular apart from being fabulous. Source Code

How to use function from another file golang?

This example aims to demonstrate the various calls of a function in detail. You will learn to create and call a custom package function in main package. You will also be able to call functions of custom packages from the another package using alias.

高朗 import package inside package

This example aims to demonstrate the implementation of interfaces in Go and import your custom package. You will be able to define and declare an interface for an application in custom packages and implement that interface in your applications.

How to import structs from another package in Go?

You will learn to create your own package and import your custom package. In this example, you will see how to import structure from another or child package. You will also be able to call functions of custom packages from the main package.

HTML解析器组

Package goquery implements features similar to jQuery, including the chainable syntax, to manipulate and query an HTML document. It brings a syntax and a set of features similar to jQuery to the Go language. It is based on Go's net/html package and the CSS Selector library cascadia. Syntax-wise, it is as close as possible to jQuery, with the same method names when possible, and that warm and fuzzy chainable interface. It is hosted on GitHub, along with additional documentation in the README.md file: //github.com/puerkitobio/goquery

什么是GOPATH?

GOPATH is actually just an environment variable which shows a location to a physical directory on computer. By default, Go assumes that the folder that GOPATH shows is under user's folder. And in that case there won't be an environment variable for GOPATH. So you don't need to set it, it's automatic.

How to use a mutex to define critical sections of code and fix race conditions?

A mutex is used to create a critical section around code that ensures only one goroutine at a time can execute that code section.

How to fix race condition using Atomic 功能 in 高朗?

Race conditions occur due to unsynchronized access to shared resource and attempt to read and write to that resource at the same time. Atomic functions provide low-level locking mechanisms for synchronizing access to integers and pointers. Atomic functions generally used to fix the race condition. The functions in the atomic under sync packages provides support to synchronize goroutines by locking access to shared resources.

How to play and pause execution of goroutine?

Using channels we can play and pause execution of goroutine. A channel handles this communication by acting as a conduit between goroutines.

How to kill execution of goroutine?

A channel has a close operation that closes the channel so that a send operation on the channel cannot take place. A send operation on a closed channel will result in a panic. When a receive operation is performed on the channel, we check if the channel is closed or not, and exit from the goroutine if the channel is closed.

Catch values from Goroutines

The most natural way to fetch a value from a goroutine is channels. 频道 are the pipes that connect concurrent goroutines. You can send values into channels from one goroutine and receive those values into another goroutine or in a synchronous function.

How to wait for Goroutines to Finish Execution?

The WaitGroup type of sync package, is used to wait for the program to finish all goroutines launched from the main function. It uses a counter that specifies the number of goroutines, and Wait blocks the execution of the program until the WaitGroup counter is zero. The Add method is used to add a counter to the WaitGroup. The Done method of WaitGroup is scheduled using a defer statement to decrement the WaitGroup counter. The Wait method of the WaitGroup type waits for the program to finish all goroutines. The Wait method is called inside the main function, which blocks execution until the WaitGroup counter reaches the value of zero and ensures that all goroutines are executed.

User Defined Function Types in 高朗

高朗 also support to define our own function types. The modified version of above program with function types as below:

Higher Order 功能 in 高朗

A Higher-Order function is a function that receives a function as an argument or returns the function as output. Higher order functions are functions that operate on other functions, either by taking them as arguments or by returning them. Passing 功能 as Arguments to other 功能

Closures 功能 in 高朗

Closures are a special case of anonymous functions. Closures are anonymous functions which access the variables defined outside the body of the function.

Anonymous 功能 in 高朗

An anonymous function is a function that was declared without any named identifier to refer to it. Anonymous functions can accept inputs and return outputs, just as standard functions do.

高朗函数 Returning Multiple Values

功能 in 高朗 can return multiple values, which is a helpful feature in many practical scenarios. This example declares a function with two return values and calls it from a main function.

Creating a Function in 高朗

A declaration begins with the func keyword, followed by the name you want the function to have, a pair of parentheses (), and then a block containing the function's code. The following example has a function with the name SimpleFunction. It takes no parameter and returns no values.

How to create a photo gallery in Go?

Photo gallery is a way of displaying the different images that are saved at a specific location. Here the different images are uploaded by user in a specified folder. For displaying the images first of all we need to read the directory containing the different images, and there after reading display the images one by one.

Create and Print Multi Dimensional Slice in 高朗

This is a multidimensional in slice that stores inner in slices. So each element of the slice is another in slice. This is a short declaration of a multidimensional slice.

How to write backslash in string?

To print backslash, just need to type the backslash twice. Hence, Go interpreter treat it as a single backslash character instead of escape sequence character.