Reflection in Golang

What is reflection? In computer science, reflection is the ability of a computer program to examine and modify its own structure and behavior (specifically the values, meta-data, properties and functions) at runtime. source: Wikipedia Reflection can be used for observing and modifying program execution at runtime. A reflection-oriented program component can monitor the execution of an enclosure of code and can modify itself according to a desired goal related to that enclosure....

December 21, 2015 · 6 min · Svetlin Ralchev

Performance and memory analysis of Golang programs

As we continue looking at program metrics in Golang, it is time to look at performance matrics analysis. Instrumentation Instrumentation is the process of adding code to your application to generate events to allow you to monitor application health and performance. Instrumentation allows you to profile applications. Profiling enables you to identify how long a particular method or operation takes to run and how efficient it is in terms of CPU and memory resource usage....

December 13, 2015 · 4 min · Svetlin Ralchev

Expose application metrics with expvar

To determine whether your application meets its performance objectives and to help identify bottlenecks, you need to measure your program’s performance and collect metrics. They tend to be response time, throughput, and resource utilization (how much CPU, memory, disk I/O, and network bandwidth your application consumes while performing its tasks). Metrics Metrics provide information about how close your program is to your performance goals. In addition, they also help you identify problem areas and bottlenecks within your application....

December 6, 2015 · 4 min · Svetlin Ralchev

Concurrent patterns in Golang: Context

What is concurrency? Concurrent applications have multiple computations executing during overlapping periods of time. Respectively sequential programs in which no computations can be executed in overlapping periods of time. Getting started with Context package The Context package is responsible for signal cancelation and operation deadlines for processes and server requests. The package has an context.Context interface: type Context interface { Deadline() (deadline time.Time, ok bool) Done() <-chan struct{} Err() error Value(key interface{}) interface{} } The interface provides four functions to observe the context state:...

November 29, 2015 · 4 min · Svetlin Ralchev

Data validation in Golang

Almost every application requires high data integrirty and quality. Very likely is its algorithms to behave weird and produce unexpected results due to invalid input. An important aspect of software development is data validation. In this article we will explore govalidate package that helps us to validate and sanitize any string, struct and slice in Go. The package itself is very infulenced by its javascript predaccessor validator.js. Installation Like any other Go package we should install it first:...

November 22, 2015 · 2 min · Svetlin Ralchev