How Go Exec Works
It’s common to run and wish to get results. As the command is executed in a forked child process, how results are passed back? This blog investigates how output is passed to parent process in command.Output
.
');--md-admonition-icon--abstract:url('data:image/svg+xml;charset=utf-8,');--md-admonition-icon--info:url('data:image/svg+xml;charset=utf-8,');--md-admonition-icon--tip:url('data:image/svg+xml;charset=utf-8,');--md-admonition-icon--success:url('data:image/svg+xml;charset=utf-8,');--md-admonition-icon--question:url('data:image/svg+xml;charset=utf-8,');--md-admonition-icon--warning:url('data:image/svg+xml;charset=utf-8,');--md-admonition-icon--failure:url('data:image/svg+xml;charset=utf-8,');--md-admonition-icon--danger:url('data:image/svg+xml;charset=utf-8,');--md-admonition-icon--bug:url('data:image/svg+xml;charset=utf-8,');--md-admonition-icon--example:url('data:image/svg+xml;charset=utf-8,');--md-admonition-icon--quote:url('data:image/svg+xml;charset=utf-8,');}
It’s common to run and wish to get results. As the command is executed in a forked child process, how results are passed back? This blog investigates how output is passed to parent process in command.Output
.
Usually, we write a client package to hide the logic about rpc to get the value, hide complex about network.
This article will based on the library of https://github.com/google/go-github to introduce useful experience when we want to design a client for results from the remote.
As usual, our client package needs to satisfy some requirements, which why we create a saperate package for it.
In cpp, some classes cannot be copied as their copy constructers are disable. For example, you can never pass an iostream
by value, only reference is allowed.
Based on provious blogs, we know that if we pass by pointer or interface, the value will be passed like reference.
Define and Use Error Properly in Go
Go has no way to disable the copy, but it provides a way to check whether the code not wishes to copy something.
As a developer, understanding the behaviors of grpc cannot keep away from the implementation. If we only know the high-level design but do not care about the implementation, we cannot get help in coding through our learning effects.
In this article, I will list some necessary concepts and draw some diagrams to understand implementation better.
Rpc is a way to communicate between two processes in different hosts, underlying the network. Http also the most popular protocol communicating between server and client. We can also so any network could be a way to communicate between two processes.
However, what’s the differences between a network protocol and a rpc framework? I will try to explain it based on gRPC
and http
protocol. Note that it makes no sense to compare a protocol and a framework, they don’t stay in the same layer. This article mainly focus on what difference between a rpc framework and http library which is treated as a rpc framework.