{"id":466,"date":"2026-05-29T09:00:00","date_gmt":"2026-05-29T03:30:00","guid":{"rendered":"https:\/\/smitabharat.com\/blog\/go-microservices-basics\/"},"modified":"2026-05-29T09:00:00","modified_gmt":"2026-05-29T03:30:00","slug":"go-microservices-basics","status":"publish","type":"post","link":"https:\/\/smitabharat.com\/blog\/go-microservices-basics\/","title":{"rendered":"Go Microservices Basics: Build Two Small Services"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Go microservices split one big application into small services that talk to each other over the network. In this post, you will learn what a microservice is, when it helps and when it only adds trouble. Then we will build two tiny services, an order service and an inventory service, and make them handle failures safely.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This lesson builds on <a href=\"https:\/\/smitabharat.com\/blog\/go-rest-api-tutorial\/\">Go REST API for beginners<\/a> and <a href=\"https:\/\/smitabharat.com\/blog\/go-http-client-guide\/\">Go HTTP client guide<\/a>. We also use ideas from <a href=\"https:\/\/smitabharat.com\/blog\/go-context-beginners-guide\/\">Go context for beginners<\/a> and <a href=\"https:\/\/smitabharat.com\/blog\/go-clean-architecture\/\">Go clean architecture<\/a>. So it helps to read those first.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What Are Go Microservices?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">In short, a microservice is a small program that does one job and exposes it through an API. For example, one service handles orders, another handles stock and a third sends emails. Each service has its own code, its own data and its own release cycle.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Think of a food court. Each stall cooks one kind of food, because the stalls do not share a kitchen. When the pizza stall closes for cleaning, the noodle stall keeps serving. Similarly, Go microservices let one part of a product fail or change without stopping the rest.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The opposite style is called a monolith. A monolith is one program that holds every feature. It is simple to start with, so it is often the right first choice. As a result, you should treat microservices as a tool for growth, not as a starting rule.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Why Go Microservices Matter<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Go is a popular language for services because it starts fast, uses little memory and builds into one small binary. Besides that, its standard library already includes a strong HTTP server and client. Here is what Go microservices give you.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Independent releases<\/strong>: a team can deploy the inventory service without touching orders, which lowers the risk of each release.<\/li>\n\n\n\n<li><strong>Targeted scaling<\/strong>: you run ten copies of a busy service and one copy of a quiet one.<\/li>\n\n\n\n<li><strong>Fault isolation<\/strong>: a bug in one service does not crash the others.<\/li>\n\n\n\n<li><strong>Team ownership<\/strong>: each team owns a clear boundary and its own data.<\/li>\n\n\n\n<li><strong>Technology freedom<\/strong>: services only need to agree on the API, not on the code.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">However, these benefits cost something. Every call that used to be a function call is now a network call, and networks fail. Therefore, good Go microservices spend a lot of effort on timeouts, retries and clear errors.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How Go Microservices Work<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Each service runs as its own process and listens on its own port. When the order service needs stock information, it sends an HTTP request to the inventory service. Then the inventory service answers with JSON. This is the basic pattern behind every Go microservices system, even a very large one. Then the order service decides what to do with the answer.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><a href=\"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-microservices-basics-diagram-1.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"640\" src=\"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-microservices-basics-diagram-1-1024x640.png\" alt=\"Go Microservices diagram showing a client calling the order service, which calls the inventory service with a timeout\" class=\"wp-image-457\" srcset=\"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-microservices-basics-diagram-1-1024x640.png 1024w, https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-microservices-basics-diagram-1-300x188.png 300w, https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-microservices-basics-diagram-1-768x480.png 768w, https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-microservices-basics-diagram-1-1536x960.png 1536w, https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-microservices-basics-diagram-1-2048x1280.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">A client calls the order service, which calls the inventory service over HTTP with a timeout. Each service owns its own data and can fail on its own.<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Notice that the order service never reads the inventory data directly. In other words, it only talks to the public API. This rule keeps services independent, so each team can move at its own speed. Likewise, the inventory team can change its database later, and the order service will not even notice.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">How Services Find Each Other<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Before it can call anything, the order service needs the address of the inventory service. In small setups, you pass it as an environment variable, such as <code>INVENTORY_URL<\/code>. In larger setups, tools such as Kubernetes give each service a stable name. As a result, the address does not change when a copy restarts. Your code stays the same in both cases, because it only reads the URL from the environment.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">What to Do When a Call Fails<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">A network call can fail in four common ways. The table below shows each one, plus a safe response.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Failure<\/th><th>What you see<\/th><th>Safe response<\/th><\/tr><\/thead><tbody><tr><td>Service is down<\/td><td>Connection refused<\/td><td>Return a clear error, retry later<\/td><\/tr><tr><td>Service is slow<\/td><td>No answer in time<\/td><td>Stop waiting with a timeout<\/td><\/tr><tr><td>Bad input<\/td><td>4xx status code<\/td><td>Do not retry, fix the request<\/td><\/tr><tr><td>Server bug<\/td><td>5xx status code<\/td><td>Retry a few times, then give up<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Go Microservices vs a Monolith<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Neither style is better in every case. The table below compares them side by side.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Feature<\/th><th>Monolith<\/th><th>Microservices<\/th><\/tr><\/thead><tbody><tr><td>Deploying<\/td><td>One unit, all at once<\/td><td>Many small units<\/td><\/tr><tr><td>Calls between parts<\/td><td>Function calls<\/td><td>Network calls<\/td><\/tr><tr><td>Debugging<\/td><td>One log, one process<\/td><td>Many logs, many processes<\/td><\/tr><tr><td>Scaling<\/td><td>Copy the whole app<\/td><td>Copy only the busy part<\/td><\/tr><tr><td>Best for<\/td><td>Small teams, new products<\/td><td>Large teams, clear boundaries<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><a href=\"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-microservices-basics-diagram-2.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"640\" src=\"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-microservices-basics-diagram-2-1024x640.png\" alt=\"Go Microservices diagram comparing a monolith with separate services\" class=\"wp-image-458\" srcset=\"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-microservices-basics-diagram-2-1024x640.png 1024w, https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-microservices-basics-diagram-2-300x188.png 300w, https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-microservices-basics-diagram-2-768x480.png 768w, https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-microservices-basics-diagram-2-1536x960.png 1536w, https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-microservices-basics-diagram-2-2048x1280.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">A monolith keeps every feature in one process, while microservices split features into separate processes that call each other over the network.<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">So when should you use which? Start with a well-organised monolith, then grow from there. Later, split out a service when one team needs to release alone. Also split it out when one part needs very different scaling. In both cases, the reason should be a real problem, not a trend.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Go Microservices Hands-On: Orders and Inventory<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Now let&#8217;s build a small example. The inventory service answers stock questions, while the order service calls it before accepting an order. Both run in one program here, using <code>httptest.NewServer<\/code>, so you can test everything in a single file.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 1: The Inventory Service<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">First, the inventory service keeps a map of stock and answers <code>GET \/stock\/{sku}<\/code>. It returns 404 when the product is unknown.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>func inventoryHandler() http.Handler {\n\tstock := map[string]int{\"GO-BOOK\": 12, \"GO-MUG\": 0}\n\tmux := http.NewServeMux()\n\tmux.HandleFunc(\"GET \/stock\/{sku}\", func(w http.ResponseWriter, r *http.Request) {\n\t\tqty, ok := stock[r.PathValue(\"sku\")]\n\t\tif !ok {\n\t\t\thttp.Error(w, \"unknown sku\", http.StatusNotFound)\n\t\t\treturn\n\t\t}\n\t\tjson.NewEncoder(w).Encode(map[string]int{\"quantity\": qty})\n\t})\n\treturn mux\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Step 2: The Order Service Client<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Next, the order service calls inventory. It sends the caller&#8217;s context along, so a cancelled request stops the whole chain. It also wraps errors with <code>%w<\/code>, which keeps the cause for later checks.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>type Orders struct {\n\tinventoryURL string\n\tclient       *http.Client\n}\n\nfunc (o *Orders) Place(ctx context.Context, sku string) (string, error) {\n\treq, err := http.NewRequestWithContext(ctx, http.MethodGet, o.inventoryURL+\"\/stock\/\"+sku, nil)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tresp, err := o.client.Do(req)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"inventory unreachable: %w\", err)\n\t}\n\tdefer resp.Body.Close()\n\tif resp.StatusCode != http.StatusOK {\n\t\treturn \"\", fmt.Errorf(\"inventory returned %d\", resp.StatusCode)\n\t}\n\tvar out struct{ Quantity int }\n\tif err := json.NewDecoder(resp.Body).Decode(&amp;out); err != nil {\n\t\treturn \"\", err\n\t}\n\tif out.Quantity == 0 {\n\t\treturn \"out of stock\", nil\n\t}\n\treturn fmt.Sprintf(\"order placed, %d left\", out.Quantity-1), nil\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Let&#8217;s look at the key lines. <code>NewRequestWithContext<\/code> ties the call to the caller&#8217;s context, so a cancelled request stops early. The check on <code>StatusCode<\/code> turns a bad reply into a clear error. This step is the heart of safe Go microservices code. Finally, the stock check is business logic that stays inside the order service.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 3: Run Both Services<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Then we start the inventory service, create the order service with a 200 millisecond timeout and place three orders. After that, we shut inventory down and try again.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>func main() {\n\tinv := httptest.NewServer(inventoryHandler())\n\torders := &amp;Orders{inventoryURL: inv.URL, client: &amp;http.Client{Timeout: 200 * time.Millisecond}}\n\n\tfor _, sku := range []string{\"GO-BOOK\", \"GO-MUG\", \"GO-PEN\"} {\n\t\tres, err := orders.Place(context.Background(), sku)\n\t\tfmt.Printf(\"%-8s -&gt; %q err=%v\\n\", sku, res, err)\n\t}\n\n\tinv.Close() \/\/ the inventory service goes down\n\t_, err := orders.Place(context.Background(), \"GO-BOOK\")\n\tfmt.Println(\"service down -&gt;\", err != nil)\n\tfmt.Println(err)\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Here is the real output from our run. The port number changes on every run, because the test server picks a free port.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>GO-BOOK  -&gt; \"order placed, 11 left\" err=&lt;nil&gt;\nGO-MUG   -&gt; \"out of stock\" err=&lt;nil&gt;\nGO-PEN   -&gt; \"\" err=inventory returned 404\nservice down -&gt; true\ninventory unreachable: Get \"http:\/\/127.0.0.1:40905\/stock\/GO-BOOK\": dial tcp 127.0.0.1:40905: connect: connection refused<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">As you can see, each case produces a different, clear result. The service did not hang or crash when inventory went away. Instead, it returned a useful error that the caller can show or retry. Also, the 404 case is not a network failure, so the code treats it as a normal answer. This difference matters, because you retry network failures but not bad requests.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Common Mistakes with Go Microservices<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Splitting too early<\/strong>: many small services add work before you have the users to justify it. So start with a monolith, and split later when the pain is real.<\/li>\n\n\n\n<li><strong>No timeouts<\/strong>: the default HTTP client waits forever. Therefore, always set <code>Timeout<\/code> or use a context deadline.<\/li>\n\n\n\n<li><strong>Shared databases<\/strong>: two services that write to one database are tightly coupled. Instead, give each service its own data.<\/li>\n\n\n\n<li><strong>Chatty calls<\/strong>: ten network calls to build one page are slow. So design APIs that return what the caller needs.<\/li>\n\n\n\n<li><strong>No tracing or logs<\/strong>: a request that crosses three services is hard to follow. Therefore, pass a request ID through every call.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Best Practices for Go Microservices<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Keep each service small and focused<\/strong>, because one clear job is easier to own and test.<\/li>\n\n\n\n<li><strong>Version your APIs<\/strong>, since callers upgrade at different times.<\/li>\n\n\n\n<li><strong>Add health endpoints<\/strong>, so the platform can restart broken copies.<\/li>\n\n\n\n<li><strong>Use structured logs with a request ID<\/strong>, which makes cross-service debugging possible.<\/li>\n\n\n\n<li><strong>Shut down gracefully<\/strong>, so running requests finish before a copy stops.<\/li>\n\n\n\n<li>**Test with <code>httptest<\/code>**, because it makes service tests fast and reliable. Also, it needs no real network setup.<\/li>\n\n\n\n<li><strong>Document the API for other teams<\/strong>, since a service is only useful when callers know how to use it.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Practice Task<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">To practise Go microservices, add a third service called <code>pricing<\/code> that returns the price of a SKU. Keep it as small as the inventory service. Then make the order service call both services and return a message such as &#8220;ordered GO-BOOK for 29.50&#8221;.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Hint: call the two services one after the other first, since that is the easiest version. After that, try calling them at the same time with two goroutines and a <code>WaitGroup<\/code>, and compare the total time.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Official Resources<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">These pages describe the packages and design ideas used in this lesson, and they are worth a bookmark.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/pkg.go.dev\/net\/http\">net\/http package documentation<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/pkg.go.dev\/net\/http\/httptest\">net\/http\/httptest package documentation<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/go.dev\/blog\/context\">Go blog: Go Concurrency Patterns, Context<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Quick Recap<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Go microservices are small programs that each do one job and talk over HTTP.<\/li>\n\n\n\n<li>Start with a monolith, and split a service only when you have a clear reason.<\/li>\n\n\n\n<li>Every network call can fail, so set timeouts and handle errors.<\/li>\n\n\n\n<li>Pass the caller&#8217;s context so cancellation travels through the chain.<\/li>\n\n\n\n<li>Keep data private to each service and share only through the API.<\/li>\n\n\n\n<li>Add health checks, logs with request IDs and graceful shutdown.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">What&#8217;s Next?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">By now, you can build two services that talk to each other, and you know how they fail. Still, a platform needs a way to ask each service if it is alive and ready. So next, we will add health check endpoints.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Next up: <a href=\"https:\/\/smitabharat.com\/blog\/go-health-checks-readiness\/\">Go health checks with liveness and readiness probes<\/a><\/p>\n\n","protected":false},"excerpt":{"rendered":"<p>Go microservices split one big application into small services that talk to each other over the network. In this post, you will learn what&hellip;<\/p>\n","protected":false},"author":1,"featured_media":459,"comment_status":"","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_swapz_level":"","_swapz_series_part":0,"_swapz_hide_toc":false,"_swapz_hide_featured":false,"_swapz_description":"","footnotes":""},"categories":[15],"tags":[11,85,77],"swapz_series":[],"class_list":["post-466","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-go-lang","tag-go-lang","tag-go-microservices","tag-intermediate"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.9 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Go Microservices Basics: Build Two Small Services<\/title>\n<meta name=\"description\" content=\"Learn Go microservices step by step: when to split a monolith, build an order and inventory service, set timeouts and handle failures safely.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/smitabharat.com\/blog\/go-microservices-basics\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Go Microservices Basics: Build Two Small Services\" \/>\n<meta property=\"og:description\" content=\"Learn Go microservices step by step: when to split a monolith, build an order and inventory service, set timeouts and handle failures safely.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/smitabharat.com\/blog\/go-microservices-basics\/\" \/>\n<meta property=\"og:site_name\" content=\"Smita Bharat - Blog\" \/>\n<meta property=\"article:published_time\" content=\"2026-05-29T03:30:00+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-microservices-basics-featured.png\" \/>\n\t<meta property=\"og:image:width\" content=\"2400\" \/>\n\t<meta property=\"og:image:height\" content=\"1260\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Smita\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Smita\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-microservices-basics\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-microservices-basics\\\/\"},\"author\":{\"name\":\"Smita\",\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/#\\\/schema\\\/person\\\/27a1b1067d396703215c54acedbfd339\"},\"headline\":\"Go Microservices Basics: Build Two Small Services\",\"datePublished\":\"2026-05-29T03:30:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-microservices-basics\\\/\"},\"wordCount\":1567,\"publisher\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/#\\\/schema\\\/person\\\/27a1b1067d396703215c54acedbfd339\"},\"image\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-microservices-basics\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/10\\\/go-microservices-basics-featured.png\",\"keywords\":[\"Go Lang\",\"Go Microservices\",\"Intermediate\"],\"articleSection\":[\"Go Lang\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-microservices-basics\\\/\",\"url\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-microservices-basics\\\/\",\"name\":\"Go Microservices Basics: Build Two Small Services\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-microservices-basics\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-microservices-basics\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/10\\\/go-microservices-basics-featured.png\",\"datePublished\":\"2026-05-29T03:30:00+00:00\",\"description\":\"Learn Go microservices step by step: when to split a monolith, build an order and inventory service, set timeouts and handle failures safely.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-microservices-basics\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-microservices-basics\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-microservices-basics\\\/#primaryimage\",\"url\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/10\\\/go-microservices-basics-featured.png\",\"contentUrl\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/10\\\/go-microservices-basics-featured.png\",\"width\":2400,\"height\":1260,\"caption\":\"Go Microservices featured image: order service, timeout and service down cards\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-microservices-basics\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Go Microservices Basics: Build Two Small Services\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/\",\"name\":\"Smita Bharat Blog\",\"description\":\"Golang &amp; Backend Development Tutorials and Interview Questions\",\"publisher\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/#\\\/schema\\\/person\\\/27a1b1067d396703215c54acedbfd339\"},\"alternateName\":\"Smita Bharat\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/#\\\/schema\\\/person\\\/27a1b1067d396703215c54acedbfd339\",\"name\":\"Smita\",\"logo\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/#\\\/schema\\\/person\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/smitabharat.com\\\/blog\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Go Microservices Basics: Build Two Small Services","description":"Learn Go microservices step by step: when to split a monolith, build an order and inventory service, set timeouts and handle failures safely.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/smitabharat.com\/blog\/go-microservices-basics\/","og_locale":"en_US","og_type":"article","og_title":"Go Microservices Basics: Build Two Small Services","og_description":"Learn Go microservices step by step: when to split a monolith, build an order and inventory service, set timeouts and handle failures safely.","og_url":"https:\/\/smitabharat.com\/blog\/go-microservices-basics\/","og_site_name":"Smita Bharat - Blog","article_published_time":"2026-05-29T03:30:00+00:00","og_image":[{"width":2400,"height":1260,"url":"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-microservices-basics-featured.png","type":"image\/png"}],"author":"Smita","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Smita","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/smitabharat.com\/blog\/go-microservices-basics\/#article","isPartOf":{"@id":"https:\/\/smitabharat.com\/blog\/go-microservices-basics\/"},"author":{"name":"Smita","@id":"https:\/\/smitabharat.com\/blog\/#\/schema\/person\/27a1b1067d396703215c54acedbfd339"},"headline":"Go Microservices Basics: Build Two Small Services","datePublished":"2026-05-29T03:30:00+00:00","mainEntityOfPage":{"@id":"https:\/\/smitabharat.com\/blog\/go-microservices-basics\/"},"wordCount":1567,"publisher":{"@id":"https:\/\/smitabharat.com\/blog\/#\/schema\/person\/27a1b1067d396703215c54acedbfd339"},"image":{"@id":"https:\/\/smitabharat.com\/blog\/go-microservices-basics\/#primaryimage"},"thumbnailUrl":"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-microservices-basics-featured.png","keywords":["Go Lang","Go Microservices","Intermediate"],"articleSection":["Go Lang"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/smitabharat.com\/blog\/go-microservices-basics\/","url":"https:\/\/smitabharat.com\/blog\/go-microservices-basics\/","name":"Go Microservices Basics: Build Two Small Services","isPartOf":{"@id":"https:\/\/smitabharat.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/smitabharat.com\/blog\/go-microservices-basics\/#primaryimage"},"image":{"@id":"https:\/\/smitabharat.com\/blog\/go-microservices-basics\/#primaryimage"},"thumbnailUrl":"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-microservices-basics-featured.png","datePublished":"2026-05-29T03:30:00+00:00","description":"Learn Go microservices step by step: when to split a monolith, build an order and inventory service, set timeouts and handle failures safely.","breadcrumb":{"@id":"https:\/\/smitabharat.com\/blog\/go-microservices-basics\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/smitabharat.com\/blog\/go-microservices-basics\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/smitabharat.com\/blog\/go-microservices-basics\/#primaryimage","url":"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-microservices-basics-featured.png","contentUrl":"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-microservices-basics-featured.png","width":2400,"height":1260,"caption":"Go Microservices featured image: order service, timeout and service down cards"},{"@type":"BreadcrumbList","@id":"https:\/\/smitabharat.com\/blog\/go-microservices-basics\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/smitabharat.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Go Microservices Basics: Build Two Small Services"}]},{"@type":"WebSite","@id":"https:\/\/smitabharat.com\/blog\/#website","url":"https:\/\/smitabharat.com\/blog\/","name":"Smita Bharat Blog","description":"Golang &amp; Backend Development Tutorials and Interview Questions","publisher":{"@id":"https:\/\/smitabharat.com\/blog\/#\/schema\/person\/27a1b1067d396703215c54acedbfd339"},"alternateName":"Smita Bharat","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/smitabharat.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/smitabharat.com\/blog\/#\/schema\/person\/27a1b1067d396703215c54acedbfd339","name":"Smita","logo":{"@id":"https:\/\/smitabharat.com\/blog\/#\/schema\/person\/image\/"},"sameAs":["https:\/\/smitabharat.com\/blog"]}]}},"_links":{"self":[{"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/posts\/466","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/comments?post=466"}],"version-history":[{"count":0,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/posts\/466\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/media\/459"}],"wp:attachment":[{"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/media?parent=466"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/categories?post=466"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/tags?post=466"},{"taxonomy":"swapz_series","embeddable":true,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/swapz_series?post=466"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}