<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Frihk Ian</title>
    <description>The latest articles on DEV Community by Frihk Ian (@frihk_ian).</description>
    <link>https://dev.to/frihk_ian</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3722900%2Fa0066d49-46b8-4c9c-aee1-170915f27351.jpg</url>
      <title>DEV Community: Frihk Ian</title>
      <link>https://dev.to/frihk_ian</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/frihk_ian"/>
    <language>en</language>
    <item>
      <title>Go for the JavaScript Developer: What Tripped Me Up and What Finally Made Sense</title>
      <dc:creator>Frihk Ian</dc:creator>
      <pubDate>Sat, 03 Oct 2026 13:43:38 +0000</pubDate>
      <link>https://dev.to/frihk_ian/go-for-the-javascript-developer-what-tripped-me-up-and-what-finally-made-sense-2765</link>
      <guid>https://dev.to/frihk_ian/go-for-the-javascript-developer-what-tripped-me-up-and-what-finally-made-sense-2765</guid>
      <description>&lt;p&gt;I was really offended when Go first refused to compile my code because of a single unused variable. In JavaScript it's perfectly possible to have a dozen such variables without anyone noticing, but Go focused on one and basically told me to clean my room. Even though I've now been using both languages for a long time, I can state that the offence I felt at the beginning has changed into respect. If you're using JavaScript and are wondering whether Go is worth your time, then this is the article I wish I had read at the start. I'll explain the areas in which I had the most difficulty: errors, concurrency, types, and tooling.&lt;/p&gt;

&lt;h2&gt;
  
  
  Two Languages, Two Personalities
&lt;/h2&gt;

&lt;p&gt;If you imagine JavaScript as someone who always agrees to requests, then it developed in a browser environment where flexibility was valued more than strictness and so will do its best to make sense of almost anything you give it. Go, on the other hand, is the friend who wants to know whether you've really thought something through; it was developed at Google by people who had grown tired of slow builds and large codebases, and its aim is to have small, boring, readable code that a stranger could understand even on a Monday morning. Neither of these two friends is better. But if you expect Go to offer the same degree of freedom as JavaScript, you'll end up arguing with the compiler during your first week; however, if you realise that it is trying to protect you, those arguments will disappear a lot sooner.&lt;/p&gt;

&lt;h2&gt;
  
  
  Errors: Thrown Versus Returned
&lt;/h2&gt;

&lt;p&gt;This was the most important mental shift for me, so permit me to make it clear. In JavaScript, errors are raised and caught at a higher level, which means a function can fail without its signature providing a warning.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nf"&gt;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the programming language Go, errors are treated as ordinary return values rather than exceptional events, so a function will explicitly return both its result and an error. This requires the developer to handle potential errors directly at the location where they may occur, as shown in the accompanying code example. For instance, after attempting to parse input using json.Unmarshal, the Go function immediately checks if an error was returned and deals with it before proceeding; this explicit pattern contrasts with JavaScript’s approach, where error handling is decoupled from the function’s interface.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="n"&gt;Config&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Unmarshal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;input&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="no"&gt;nil&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Errorf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"parsing config: %w"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="n"&gt;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Allow me to be straightforward with you: at first, err != nil did do seem like never-ending repetition. However, I then realised what advantage it was giving me. Whenever the program could fail, that fact was clearly shown right on the page, and you couldn't ignore a failure path without the code looking obviously incomplete. The more you added code, the fewer nasty surprises you had at three in the morning.&lt;/p&gt;

&lt;h2&gt;
  
  
  Concurrency: One Thread Versus Many
&lt;/h2&gt;

&lt;p&gt;Here's a fun method of illustrating the difference. JavaScript makes use of a single thread and an event loop. In the case of using async and await, no processing takes place in parallel. What you're actually doing is asking the runtime to carry out other tasks while it is waiting for something slow, such as a network call. The approach is simple, and as a result you rarely have to concern yourself with two bits of code accessing the same data at the same time.&lt;/p&gt;

&lt;p&gt;Go takes a distinct approach to concurrency: goroutines are lightweight threads managed by the Go runtime and can execute tasks concurrently, utilizing multiple CPU cores when available. You initiate a new goroutine by prefixing a function call with the keyword go, which instructs the runtime to schedule that function for asynchronous, potentially parallel execution.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;go&lt;/span&gt; &lt;span class="k"&gt;func&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;-&lt;/span&gt; &lt;span class="n"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}()&lt;/span&gt;
&lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;-&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The power is genuine, and it brings with it a number of problems which you should be aware of. Since goroutines share memory, it is possible to encounter data races in which two of them read from and write to the same variable without coordinating, and deadlocks in which they wait for each other indefinitely. I have discussed both of these issues after having come across them directly. Although Go provides you with good tools such as channels, mutexes, and the race detector, it won't prevent you from using them incorrectly. JavaScript's runtime protects you from all the kinds of bugs involved here, whereas in Go that protection is up to you.&lt;/p&gt;

&lt;h2&gt;
  
  
  Types: Suggestion Versus Contract
&lt;/h2&gt;

&lt;p&gt;If you're already using TypeScript, static typing won't intimidate you; in contrast, TypeScript's types disappear at runtime and can be ignored using any, whereas in Go the types constitute a contract that is enforced by the compiler. There's also no ordinary undefined or null value to run into, since every type has a zero value—an unset integer is 0, an unset string is "", and an unset boolean is false. This eliminates the entire class of "cannot read property of undefined" errors. At the same time, it raises a subtle new issue regarding how to distinguish between 'the user sent zero' and 'the user sent nothing', and from that point on pointers and the omitempty tag on JSON fields prove to be useful.&lt;/p&gt;

&lt;p&gt;The way interfaces function is also interesting, and that's my favourite aspect. A Go type automatically satisfies an interface whenever it has the appropriate methods, without any need for an implements keyword. It does feel a bit strange at first, but then you realise that you can define a very small interface exactly where you're using something and substitute a dummy one when testing, which in turn makes your code extremely easy to test.&lt;/p&gt;

&lt;h2&gt;
  
  
  Tooling: The Stuff You Feel Every Day
&lt;/h2&gt;

&lt;p&gt;It was here that Go made me accept it. There's just one formatter, gofmt, and everybody uses it, so there are no disagreements about code style. The standard library is so thorough that you can create a fully functioning HTTP server using just net/http and nothing else, whereas the JavaScript version typically starts by picking a framework and then installing a dozen packages. Testing and benchmarking are included, and the final program is a single binary that you can copy to a server, without having to install a runtime and without needing to drag along a node_modules folder. If you care about deployment, as I am becoming more and more concerned about doing, then this level of simplicity is difficult to exaggerate.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I Still Love About JavaScript
&lt;/h2&gt;

&lt;p&gt;Don't imagine that this is a letter announcing a breakup because it isn't. JavaScript remains my default choice whenever I'm working with the browser, and the environment it offers for creating interfaces has no equal, which is the reason I continue to turn to React and Next.js. With Go, the verbose syntax can become tedious when all you want to do is quickly prototype something, and working with loosely defined data is more difficult than it is in a language where an object can hold any type of value. The real question to ask is never "which language is better?" but rather "which trade-offs suit this job?"&lt;/p&gt;

&lt;h2&gt;
  
  
  Why I Use Both
&lt;/h2&gt;

&lt;p&gt;The system I'm using at the moment has Go on the back end and JS on the front end. Go is used in the areas where it's important to have correctness, good performance, and easy deployment, while JavaScript is employed for the parts that users actually see. There's a benefit that I didn't anticipate: by expressing the same concept in two different languages based on different philosophies, you are compelled to understand the idea itself rather than merely the syntax. If you're confined to a single language, switching to the way of thinking from another language is one of the quickest methods for improving your skills.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Bottom Line
&lt;/h2&gt;

&lt;p&gt;If you're a JavaScript developer who's interested in Go, you can look forward to being annoyed for a week before coming to appreciate it after a year. You should learn to accept returned errors, show respect for goroutines before you start to trust them, and let the compiler contradict you rather than opposing it. As a result, your code will become more explicit and you'll place greater trust in it. Since I myself am still investigating the more advanced aspects of Go, please tell me in the comments which part caused the most difficulty for you, and I'll write about that next.&lt;/p&gt;

</description>
      <category>go</category>
      <category>javascript</category>
      <category>programming</category>
      <category>softwaredevelopment</category>
    </item>
    <item>
      <title>Lessons From Learning With No Teacher</title>
      <dc:creator>Frihk Ian</dc:creator>
      <pubDate>Fri, 02 Oct 2026 11:04:24 +0000</pubDate>
      <link>https://dev.to/frihk_ian/lessons-from-learning-with-no-teacher-pi9</link>
      <guid>https://dev.to/frihk_ian/lessons-from-learning-with-no-teacher-pi9</guid>
      <description>&lt;p&gt;When you first go into Zone01Kisumu, the most obvious thing is that there is no traditional lecture. There is no lecturer at the front, no slide presentation for you to transcribe, and no one available to help you when you encounter difficulties. Rather, you are given a task, a number of peers who are just as uncertain as yourself, and a deadline. At the beginning I had expected a standard bootcamp, but what actually happened was more like being put into a workshop where you learn to use the tools by getting hands-on with them. The following article gives the honest account that I wished I had been given earlier on: it sets out effective strategies for this kind of learning method, points out the real difficulties, and explains the way I decided when I had been stuck for long enough. But in order to understand all these points, it is first necessary to understand the reason for the school's structure.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why This Model Exists
&lt;/h2&gt;

&lt;p&gt;Zone01Kisumu is part of the 01 Edu curriculum and uses a peer-driven, project-based approach to education. The basic idea is that if a teacher gives all the answers, students mainly end up learning how to follow instructions; on the other hand, if they are asked to come up with solutions before being given the explanations, they acquire the ability to teach themselves. The projects make up the curriculum, and peers act as resources, reviewers, and members of the audience. Even though this might at first sound like a simple phrase, it really does alter the way a difficult day feels. Rather than thinking, "I didn't understand the lecture," the new challenge becomes, "I don't even know what to search for." Although this shift can be uncomfortable, it is exactly what allows the system to achieve its most important benefits, which become obvious soon after students start working on the projects.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Actually Works
&lt;/h2&gt;

&lt;p&gt;One of the main advantages is that concepts aren't left abstract for very long. If you are given the job of building a working program based on a specification, real-world problems come up right away, for example, unclear requirements, cases that have not been considered, and bugs which only show up when different parts of your code are put together. More have I learned about error handling from a program that failed during a review than from any chapter in a textbook on the topic. Another important benefit is the role of the reviewer; it becomes a standard part of the process to explain your work. When a fellow worker looks at your project, you have to defend your decisions orally, which makes it hard to hide mistakes during a thorough discussion.&lt;/p&gt;

&lt;p&gt;The way in which these discussions are carried out also affects the way you deal with knowledge; when there is no clear authority present, you are encouraged to critically assess any claims, including your own. For instance, if a person says that a certain method is faster, the natural reaction is to say, "let's measure it." I have adopted this practice in my work as a technical writer by regularly carrying out benchmarks before making any assertions. Yet this habit has its disadvantages and involves certain costs which promotional materials seldom mention, thus bringing us to the more difficult parts of this educational approach.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is Genuinely Hard
&lt;/h2&gt;

&lt;p&gt;The kind of autonomy which helps to develop problem-solving abilities may at the same time lead to a gradual and unexpectedly isolating experience. There are times when you can get stuck on a matter that might have been settled with just a short explanation, and yet end up spending hours working on it all by yourself. In some cases this difficulty is deliberate and has advantages; in other cases, it is simply inefficient. The problem is to tell the difference between these two situations. Without an expert checking your understanding, a misconception can survive for weeks because everyone around you shares it.&lt;/p&gt;

&lt;p&gt;The risk grows if you start comparing yourself with the people around you. In a group of individuals who are of a similar age or social position, some will jump right into a topic while others will take longer, and it's easy to judge yourself by those who are ahead that week. Comparison is the fastest way of sapping the motivation you need in order to keep going, and I had to learn to concentrate on my own progress rather than on the mental leaderboard. Once I had stopped measuring myself against other people, a more practical question arose: if I'm going to have to face all the difficulties on my own, how am I ever going to know when the struggle has stopped being useful?&lt;/p&gt;

&lt;h2&gt;
  
  
  How I Decide I Have Been Stuck Long Enough
&lt;/h2&gt;

&lt;p&gt;Instead of sticking to strict time limits, I follow a general rule. At the beginning, I try to clearly and briefly state the problem, since doing so usually helps me to identify the real issue. When this method doesn't work, I take the smallest possible version of the faulty code and isolate it in order to see whether the error still occurs, a procedure which generally gets me nearer to a solution. Only then do I refer to the documentation and afterward ask a colleague for help. Once an hour has passed and I haven't made any progress, I realize that continuing to struggle is pointless and so I ask for assistance without delay. It should be mentioned that the success of this approach depends on the way the following question is asked of others.&lt;/p&gt;

&lt;h2&gt;
  
  
  Asking Well Is a Skill
&lt;/h2&gt;

&lt;p&gt;The ability to ask effective questions is much like that of an engineer, and I first learned this lesson here. It's not very helpful just to say "It doesn't work." On the other hand, if you give specific details such as "I expected this output but received that one and have already ruled out these two possible causes," you usually get a quick and useful response. By outlining the steps you've already taken, you show respect for people's time, and this in turn leads to more worthwhile answers. This kind of skill doesn't stay limited to the bootcamp; it meets the requirements of a junior developer in a professional team. Once you get into the habit of doing this, it naturally encourages you to take on the role of answering questions and reviewing other people's work.&lt;/p&gt;

&lt;h2&gt;
  
  
  Learning to Give Feedback
&lt;/h2&gt;

&lt;p&gt;Another element of the peer-driven model involves the considerable amount of time spent examining other people's work, a skill that is highly valuable. At first, I would give only a superficial approval in order to prevent disagreement or concentrate on minor and unimportant matters. Later on, I learned how to tell the difference between real errors and alternative methods, and started to give explanations with my feedback. As a result, my ability to take in feedback also improved, reinforcing the idea that criticism of code does not amount to a personal attack. This distinction is important in professional settings where every pull request is subjected to review, leading to the final decision as to whether this approach is appropriate for each individual.&lt;/p&gt;

&lt;h2&gt;
  
  
  Would I Recommend It?
&lt;/h2&gt;

&lt;p&gt;It depends on the individual since the appropriateness of this method varies from person to person. For people who value structure, prefer clear direction, and like to receive regular feedback, this approach might seem rather demanding. On the other hand, individuals who are at ease with uncertainty and who enjoy working out problems on their own, seeing setbacks as an essential part of deep learning, may find this kind of environment very beneficial when it comes to developing their skills as a developer. The most valuable thing for me was not just obtaining a list of technologies, but rather acquiring a practical method for dealing with unfamiliar problems, a skill which still holds value even as the specific tools change. The entire approach consists of a full explanation. As no one will tell you about it, the key point you need to take away is that you have to learn how to define the problem, break it down, check your assumptions, ask good questions, and then look at the situation in a kind way, with these habits staying with you longer than any particular framework. You should realize when considering a project-based bootcamp that the difficult days are real and that it is also during these days that the most growth occurs. I am still learning, and I expect to keep doing so in this way for a long time.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>education</category>
      <category>learning</category>
    </item>
    <item>
      <title>Five Years Ago, "Junior Developer" Meant Something Different. Here's What I'm Facing Now.</title>
      <dc:creator>Frihk Ian</dc:creator>
      <pubDate>Fri, 02 Oct 2026 08:49:10 +0000</pubDate>
      <link>https://dev.to/frihk_ian/five-years-ago-junior-developer-meant-something-different-heres-what-im-facing-now-35ia</link>
      <guid>https://dev.to/frihk_ian/five-years-ago-junior-developer-meant-something-different-heres-what-im-facing-now-35ia</guid>
      <description>&lt;p&gt;Over time, the meaning of "junior" shifted from "beginner" to something else. I first noticed this change when I read a job posting for a junior developer. The job description listed requirements like a "frontend framework" and, for the backend, "a programming language," "SQL and NoSQL databases," "Docker," "CI/CD," "Cloud basics," "Testing," and even "experience with AI-assisted development." But what truly made me laugh was the next line: 1-3 years of professional experience—for a beginning position. Where is a beginner supposed to get that experience before their first job?&lt;/p&gt;

&lt;p&gt;I'm a junior developer in Go, JavaScript, and Python; I build with React and Next.js, and I have a background in physics. I'm in a project-based bootcamp called Zone01, where no answers are given, and you learn by doing. I'm in the squeeze, not the outside looking in, and if you are thinking of joining us right now, you deserve a true picture of what has changed.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Bar Was Lower, and I'm Not Complaining About That
&lt;/h2&gt;

&lt;p&gt;To truly appreciate how much has changed, it's important to look back at how things used to be. First, I will be fair to the past. It's been about five years since the path to a first developer position went something like this: learn a language or two, make some projects, complete a bootcamp or course, assemble a portfolio, and slog through interviews. Businesses were hiring like crazy, remote work had just blown up, and many employers were more than happy to take a gamble on a new employee and train them on the job. And the world was full of problems, and even then, access was unequal. What was expected for a first job, however, was "show me that you can learn, and that you have constructed something. The baseline today is more towards "show me you have done a lot of the work."&lt;/p&gt;

&lt;h2&gt;
  
  
  Fast forward to today, and the expectations have shifted. A Portfolio is not all there is anymore. You Have to Prove You Can Ship.
&lt;/h2&gt;

&lt;p&gt;A to-do application used to serve as a portfolio item. Now it reads like a tutorial that you followed. Today, hiring managers want a project they see as deployed and "live" (not in a repository with a README), and that solves a real problem (not a clone of a course project).&lt;/p&gt;

&lt;p&gt;They also look for the nitty-gritty that makes software useful: authentication, a database, error handling, and validation. Tests matter because they reassure anyone who has maintained a production system, and with Docker, environment configuration and CI/CD aren't the same as someone else being able to deploy it.&lt;/p&gt;

&lt;p&gt;This is what I learned from my own projects. A Go backend with a React frontend is one thing. Containerizing it, wiring in a database, handling edge cases, and making it something another developer can pick up and run is another. Most of the learning happens in that second part, and that's what today's employers want to see evidence of.&lt;/p&gt;

&lt;p&gt;As I moved from building projects to actually making them production-ready and easy for another developer to run, I started to see the bigger picture. These real-world challenges revealed that expectations now go well beyond just getting something to work. The truth is, the bar for juniors is much higher than before—not just in shipping code, but in understanding a wide range of technologies. The Stack Got Wider, and 'Full-Stack' Became the Default.&lt;/p&gt;

&lt;p&gt;With these higher expectations for projects and deployment, the range of technical knowledge required has also grown. Five years ago, one could secure a position as a frontend developer with knowledge of HTML, CSS, JavaScript, and one framework, and it was entirely normal to specialize early on. Now the expectation is to be "T-shaped," i.e., deep in one area and competent across the stack. A frontend role can be completely silent about writing a backend endpoint, or a backend role can know nothing about containers and basic cloud services. These are all mentioned in the casual junior posts. Casual junior posts mention relational and non-relational databases, cloud platforms, and REST and GraphQL. It's not everything you need to know, but a junior should be familiar with the surface area.&lt;/p&gt;

&lt;h2&gt;
  
  
  And as the required stack broadens, one thing remains clear: fundamentals still matter.
&lt;/h2&gt;

&lt;p&gt;The irony is that tooling is far removed from its concrete origins, so you might think fundamentals don't count, but they do. Interviewers are getting more curious about the details, including how HTTP works, what happens when you enter a URL into a web browser, how a database index accelerates a query, what concurrency is, and why one data structure is better for a particular problem than another. Frameworks change every couple of years, and the people who can reason from first principles survive those changes.&lt;/p&gt;

&lt;p&gt;That's where my physics background helps. Physics teaches you how to approach a complicated system, deconstruct its rules, and get a sense of how to reason through it. That's how I approach debugging and designing a system, and it works much better than I thought it would! It also means that I cannot say, "I used the library. Need to be able to describe how something works.&lt;/p&gt;

&lt;h2&gt;
  
  
  Just as the fundamentals remain crucial, another major shift has arrived: the role of AI in entry-level work.
&lt;/h2&gt;

&lt;p&gt;This is the biggest and most controversial change. Many of the tasks that previously required junior developers a few minutes to do, such as boilerplate, simple CRUD, basic scripts, and small bug fixes, can now be completed in just a few seconds with AI assistance. Companies noticed. Some said they didn't hire as many juniors; others said the requirement has increased, since if the tool writes the boilerplate, the human still has to add something else. Employers want judgment: can you take the code and tell what is wrong, turn a fuzzy requirement into a plan, debug code that you didn't write, and tell when the AI is definitely wrong?&lt;/p&gt;

&lt;h2&gt;
  
  
  At the same time, the landscape for junior developers isn't just changing in terms of skills and tools—it's also expanding geographically.
&lt;/h2&gt;

&lt;p&gt;When developers competed for positions five years ago, much of it was local. They competed against brilliant developers from all over the world, especially for remote jobs. Bootcamps, free online courses, and a series of tech job cutbacks have flooded the entry-level pool with more qualified people, and if hundreds apply for one of those junior spots, employers don't have to worry about hiring anyone, so they don't.&lt;/p&gt;

&lt;p&gt;To the developers in Kenya and other parts of Africa, this is a two-way street. The Internet gives the world new employment opportunities from employers around the world that weren't available a generation ago, but it also exposes us, right from the start of the application process, to a global standard. This is not something to worry about. That is an excuse to think about what you can make visible.&lt;/p&gt;

&lt;h2&gt;
  
  
  Visibility in the community has become just as important as technical skills.
&lt;/h2&gt;

&lt;p&gt;More and more, code alone isn't enough. Having a clean GitHub profile, a portfolio site, and blogging about what you've learned are all evidence of thinking, communicating, and completing tasks. I write technical articles partly because you have to know something thoroughly to write an interesting article about it, but it also makes it easier for others to follow my thinking.&lt;/p&gt;

&lt;p&gt;People don't seem to realize how valuable effective communication is. Team distribution: Clear pull request descriptions, good questions, and explanations of trade-offs are all characteristics people look for, even if the job description doesn't explicitly mention them.&lt;/p&gt;

&lt;h2&gt;
  
  
  Given all these factors, it’s natural to wonder whether this new landscape is fair.
&lt;/h2&gt;

&lt;p&gt;I don't believe employers have become unreasonable, and I don't believe juniors are just lazy. The reality is more painful. A few things contributed to the market tightening after the hiring frenzy ended and companies grew more conservative; tools improved the productivity of experienced developers, diminishing the perceived need to train novices. Meanwhile, the number of people looking to get into the business outpaced the number of jobs being created.&lt;/p&gt;

&lt;p&gt;The result is a mismatch between rising expectations and a shrinking number of on-ramps. But part of that is a problem in the structure of the industry, and a problem that companies have to address: if they never hire a junior, they will have to wait to hire a senior. That's another story for another article, but this one here, I can only control my side of the conversation.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I'm Doing About It
&lt;/h2&gt;

&lt;p&gt;Complaining is good for 10 minutes, and then the job offers are still right there. So, my approach is to make fewer projects, but finish them right - one project that you deployed, tested, and documented is better than five projects that are halfway finished. I go deep on fundamentals because I want to know how something works, instead of memorizing how to call it; and I don't rely on AI to do the work for me, but I use it as a partner to explain to myself, line by line, anything I ship.&lt;/p&gt;

&lt;p&gt;The other key element is collaboration. Group projects helped me learn about Git conflicts, code review, and communicating under pressure: all of which a single tutorial can't. Not only that, but I write and share as much as I can, which means that every article or repository is a public record of what I know and that I try to be patient with the timeline. The road is longer than it was 5 years ago, and taking it saves energy for the actual work.&lt;/p&gt;

&lt;h2&gt;
  
  
  In the end, here’s what it comes down to:
&lt;/h2&gt;

&lt;p&gt;If you're a junior developer who feels like they have to keep shifting the goalposts, you're not alone. They did. What used to be a middle-level job now shows up in entry-level postings; the competition is international; and tools have changed the definition of "entry-level work."&lt;/p&gt;

&lt;p&gt;However, the road is still open. It pays for people who send authentic products, see what is beneath the surface, use new tools with good judgment, and keep publicly demonstrating their work. That's tough, but it's learnable! I am still traveling; if you are, keep traveling.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>beginners</category>
      <category>softwareengineering</category>
    </item>
    <item>
      <title>I Got a Signed Job Offer Letter for a Job that Never Existed</title>
      <dc:creator>Frihk Ian</dc:creator>
      <pubDate>Tue, 29 Sep 2026 09:02:56 +0000</pubDate>
      <link>https://dev.to/frihk_ian/i-got-a-signed-job-offer-letter-for-a-job-that-never-existed-5f1d</link>
      <guid>https://dev.to/frihk_ian/i-got-a-signed-job-offer-letter-for-a-job-that-never-existed-5f1d</guid>
      <description>&lt;p&gt;I passed a 48-hour technical challenge, received an offer letter, and then lost the job because I had to enter and upload my ID number and make a payment on a page to complete a background check. I already knew what this was, but I needed to verify my suspicions.&lt;/p&gt;

&lt;h2&gt;
  
  
  The offer that wasn’t.
&lt;/h2&gt;

&lt;p&gt;The email message felt authentic: it was addressed to me by my name, included details from my resume, and congratulated me on being selected from “a massive pool of applicants” for a job with a company named WeatherAI. The challenge was to build anything using their API, then submit a repo and live deployment link. I created it, submitted it, and received ‘passed’ with a signed offer letter from embed &lt;code&gt;hr@weather-ai.co&lt;/code&gt; at the near 48-hour mark. Next came a Background Check.&lt;/p&gt;

&lt;p&gt;I had already come across yet another developer who had written about this very same procedure–the same company, the same challenge, the same offer letter, the same redirect. When I visited a website called &lt;code&gt;beta.verika.org&lt;/code&gt;, I got a page to enter my ID number, proof of address, KRA PIN, phone number, email, and certificates, and to top it off, I was supposed to pay a fee to them; I wasn't discovering a scam. I was verifying one. I had no item submitted when I closed the tab.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why it lasted for more than 48 hours
&lt;/h2&gt;

&lt;p&gt;The vast majority of the scam warning posts tell you about some blatantly false item. This one wasn’t. The API was real: full docs, working endpoints, real JSON weather data, tiered rates (up to 1000 requests per month), even SMS farmer notifications, and Paystack billing integrated into the docs for Kenya. It was like a real weather API for East Africa. The invite email mentioned “the scaling challenges we face on a day-to-day basis,” so I built a caching, quota-aware gateway around that constraint instead of just a weather display, and shipped it inside the window. A good challenge remains a challenge. What follows is the key to knowing what you are dealing with.&lt;/p&gt;

&lt;h2&gt;
  
  
  The tell, and what I walked away with
&lt;/h2&gt;

&lt;p&gt;A background-check page that asks the candidate to pay for his/her background check is enough. Real employers do not bill the candidate for any kind of background check, whether it is called an “expense,” a “background check fee,” or something else, but pay for the background check themselves through a named background check vendor. The developer whose account led me here described the identical site, challenge, and fee. Two engineers, months apart, running through an identical script isn't a coincidence. It's a template.&lt;/p&gt;

&lt;p&gt;The company isn't really there, but the 48 hours weren't wasted. I designed the project around the same restriction outlined by the fake job, and shipped a working FastAPI gateway with the following features: response caching (no repeat requests should make it to the upstream API twice), persistent quota tracking (the API itself does not track quotas, and storing them locally in SQLite is easier), retry + backoff logic specific to the errors I wanted to retry, and a React UI deployed live at weatheraigateway.onrender.com (source). The frontend, known as Kenya Weather Log, allows anyone to browse the real-time weather conditions in Nairobi, Kisumu, Bomet, and Mombasa: a little product that survived the phony job that gave it birth. But the fact that the offer was fake did not deter anyone from believing it was real.&lt;/p&gt;

&lt;h2&gt;
  
  
  What to look out for and what to do.
&lt;/h2&gt;

&lt;p&gt;A frictionless hiring process means no humans are holding it back. Don’t take it as a compliment if the challenge seems to be a craptacular mirrored version of your CV. Any kind of payment request, no matter how it’s worded, is disqualifying. Compliance language that doesn't match your country is copied, not diligent. Someone else already publishing your exact story is confirmation, not coincidence. If you have seen it: don’t pay or upload anything; report the domains through WHOIS and report wherever the domains were seen. If you have already submitted documents or payment, inform the DCI cybercrime department and notify your bank of your ID number and KRA PIN. Do not delete anything you have created. First, keep in mind that a job search is one of the moments we are most likely to be vulnerable to this type of attack – we are on the lookout for any job opening and ready to say yes with minimal hesitation. It is this enthusiasm which is under attack. Slow down anyway.&lt;/p&gt;

</description>
      <category>career</category>
      <category>cybersecurity</category>
      <category>security</category>
    </item>
    <item>
      <title>Every Automation Wave Was Supposed to Kill Programming Jobs. This Time People Actually Believe It.</title>
      <dc:creator>Frihk Ian</dc:creator>
      <pubDate>Tue, 15 Sep 2026 07:58:32 +0000</pubDate>
      <link>https://dev.to/frihk_ian/every-automation-wave-was-supposed-to-kill-programming-jobs-this-time-people-actually-believe-it-470b</link>
      <guid>https://dev.to/frihk_ian/every-automation-wave-was-supposed-to-kill-programming-jobs-this-time-people-actually-believe-it-470b</guid>
      <description>&lt;p&gt;Someone in the AI coding space recently said that the term "software engineer" will be obsolete, and we will all be "builders" or "product managers" instead, as coding is solving itself around the corner. I have come across some instances of this before. Instead of anything else, it was the way people delivered this bit of news that pulled at me this time.  Not "this year, possibly", but this year, "obviously. The sound of that is new, even though their prediction isn't.&lt;/p&gt;

&lt;p&gt;Having been here before, many times, and not in the way that people would like.&lt;/p&gt;

&lt;h2&gt;
  
  
  The pattern, if you actually look at it
&lt;/h2&gt;

&lt;p&gt;Routers and IDEs arrived decades ago, promising to enable software development five to ten times faster, and at the time they were running, people were afraid because fewer people would have to do the same amount of work. The actual result was quite the opposite. The software became infinitely easier to develop, and the number of software programs the world wanted grew exponentially, as did the number of developers required to develop them. Ten years later, Stack Overflow and Open Source did the same, and it was rightfully assumed that one's personal knowledge was devalued by the ease of access to others who had solved the same problem. It did the opposite: it lowered the bar, and more people became developers, not fewer. That friction turned developers' jobs into about double the workload, as cloud platforms took on much of the tedious work of managing their own infrastructure, and there was no more racking servers in the 2010s. Even low-code and no-code systems, which the movement's adherents originally envisioned as giving non-programmers a complete pass with code blocks and no coding whatsoever, found themselves in many markets being paid more than non-programmers who didn't use low-code or no-code systems.&lt;/p&gt;

&lt;p&gt;Each and every wave automated something true. Each individual wave saw an increase in the number of people doing the work, rather than a decrease. If that's the whole story, this should be an easy, comforting article to write.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why people believe this time is actually different
&lt;/h2&gt;

&lt;p&gt;Here's the honest complication, and I don't think it's nothing. All previous waves made you more efficient in doing the work, in typing, in looking things up, in provisioning, and in prototyping. All the previous waves have made you more efficient at work, typing, looking things up, provisioning, and prototyping. None of them spoke to the 'what' or the 'whether' a decision was the correct one. The agent who takes care of the entire lifecycle of building, selecting the architecture, coding, testing, compiling, and deployment of the features is automating another layer altogether. It's no longer eliminating friction from the job, but it's claiming judgment from the job, the part that's been completely avoided by all previous waves.&lt;/p&gt;

&lt;p&gt;Which is what makes this one feel different in the body and on the headline. And the fear does have some early confirmation: hiring of junior developers has gotten a lot softer in the last year, while the demand for engineering talent hasn't budged an inch. That's nothing. Prior waves stimulated demand in all areas. It may be a new upswing of senior judgment, and an unspoken decline in the entry level which sustained it.&lt;/p&gt;

&lt;h2&gt;
  
  
  So which is it
&lt;/h2&gt;

&lt;p&gt;This is as far as I end up; maybe I am incorrect: I believe that the trend is true at the top and downplays at the bottom. Historically, software has become easier to make. That means the world will make more, not less, of it, and more people will make software projects more easily than before. It also means there will be a greater need for more people to easily make software projects. This time, however, the typical entry-level job, the position at the bottom where they teach you the underlying basics over years of bored, technical, under-the-hood cruddy work with a senior engineer’s shadow, may still fall victim to the changes, though not because the number of developers is being reduced, but because the route into being one changes.&lt;/p&gt;

&lt;p&gt;I'm looking for your feedback on that. As a fresh entry into the workforce now, does this seem exactly what you're seeing when you go on job interviews, or is it sounding like too much? Or if you are in that self-same fear that you ever endured yourself, do you truly sense that this one is different in this 10th year's fashion? I'd prefer to have this argument in the comments rather than know the response already.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>programming</category>
      <category>softwaredevelopment</category>
      <category>vibecoding</category>
    </item>
    <item>
      <title>What are the ethical implications of AI in healthcare?</title>
      <dc:creator>Frihk Ian</dc:creator>
      <pubDate>Tue, 15 Sep 2026 07:57:42 +0000</pubDate>
      <link>https://dev.to/frihk_ian/what-are-the-ethical-implications-of-ai-in-healthcare-cbd</link>
      <guid>https://dev.to/frihk_ian/what-are-the-ethical-implications-of-ai-in-healthcare-cbd</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fw816ugbgitnds7v2id4i.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fw816ugbgitnds7v2id4i.jpeg" alt=" " width="800" height="1156"&gt;&lt;/a&gt;Take a quick glance at this meme. You've seen something like this before, haven't you? AI agreeing with something that is obviously and badly wrong. “That's correct, it was toxic.” In a tone of confidence similar to that used to tell you the capital of France. It's funny; the confidence is so far removed from correctness, and it's like that's the whole point.&lt;/p&gt;

&lt;h2&gt;
  
  
  The thing is, though. Funny when it's a food that's poisoned. But is it still funny when it's your bloodwork
&lt;/h2&gt;

&lt;p&gt;?&lt;br&gt;
That kind of tone that's certain, slick, relaxed, is already residing in actual medical gear now. Not hypothetically. Right now.&lt;/p&gt;

&lt;p&gt;To start with, the first problem is so easy: "AI can sound right when it's wrong, and in healthcare, that's wrong when it's right. Take the time to think the other way around. You are a doctor who has just been on a twelve-hour shift, or a patient who just wants someone, anyone, to tell him or her what's going on. An AI provides you with an answer; it's clean, it's confident, and it's without hesitation. Do you really plan to interrogate it? Honestly evaluate yourself. Last time you double-checked an AI, rather than taking its word for it because it sounded certain?Last time you checked a point an AI had made, rather than just believing it because it seemed like it had a big idea of itself?&lt;/p&gt;

&lt;p&gt;Now imagine yourself as that student taking the exam. Don't read about it; be it.  A person in the "scrubs" is telling you what "the system" has marked, and you're nodding your head, right? What else would you have to do? Demand a second opinion from the algorithm? When it comes to your own body, and a decision is at stake, that confidence you laughed at 30 seconds prior doesn't feel funny anymore.&lt;/p&gt;

&lt;h2&gt;
  
  
  Which leads directly into the second problem, the heavier one: When it goes wrong, who owns that?
&lt;/h2&gt;

&lt;p&gt;State that an algorithm causes a negative consequence. Who's responsible? The doctor who believed in a tool that they were told to believe in? The hospital where the software was bought and implemented in all departments? The builder of it, away from the real examination room? In reality, it's often the response of "a little bit of all these people, so no one really. Now suppose you are that person giving the explanation to a member of your family. Say out loud to someone who just lost a person they loved: "Well, the algorithm suggested it". But when no one seems to have committed a mistake, is it still an accident? Or could it be just the way we've settled for doing it these days, one tool at a time, not even voting on it?&lt;/p&gt;

&lt;p&gt;That's really all there is to it, right? The meme's success was that the stakes were fake and easily verifiable: poison or not, you would know within the hour, either way. Medicine doesn't give you a safety net of this kind. When you do not have an immediate, evident answer as to whether the confident answer was correct or not, you must play it by ear as to how much trust to place in the tone of voice emanating from a machine.&lt;/p&gt;

&lt;p&gt;So, that's where I'll leave you. The next time you hear someone, whether a doctor or a computer, state with absolute certainty that he/she knows what is happening, ask yourself what he or she is basing that certainty on. The reason for this is that you're right: it was a joke about a snack, and it was poisonous. But somewhere out there, right now, a similarly worded sentence is being repeated about somebody's diagnosis, but without the coolness, and it isn't being laughed out loud in the room.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>aiinhealthcare</category>
      <category>agents</category>
      <category>science</category>
    </item>
    <item>
      <title>Nobody Can Agree What a Software Engineer Even Does Anymore, and That's the Real Story of 2026</title>
      <dc:creator>Frihk Ian</dc:creator>
      <pubDate>Tue, 15 Sep 2026 07:53:06 +0000</pubDate>
      <link>https://dev.to/frihk_ian/nobody-can-agree-what-a-software-engineer-even-does-anymore-and-thats-the-real-story-of-2026-36f8</link>
      <guid>https://dev.to/frihk_ian/nobody-can-agree-what-a-software-engineer-even-does-anymore-and-thats-the-real-story-of-2026-36f8</guid>
      <description>&lt;p&gt;Titles in this sector have got a bit crazy. We've acquired the terms “builder”, “system thinker”, “AI orchestrator”, “product engineer”, and a few others, all referring to the same shoddy word. Over the course of a few years, we've got caught up in “builder”, “system thinker”, “AI orchestrator”, “product engineer”, and a few other unglamorous words in the same ballpark, and the actual day-to-day work beneath these umbrella terms seems to be coalescing more than ever. That, in itself, is what's really weird about me. As the work itself begins to look increasingly alike across companies, the labels are multiplying at just the right time.&lt;/p&gt;

&lt;h2&gt;
  
  
  Quite simply, the same name, a very different role.In simple terms, the same name, a very different role.
&lt;/h2&gt;

&lt;p&gt;Go to two people who both say that they are “software engineers”. One of these spends a lot of a normal week reviewing pull requests from an AI agent, writing specs so precise that the agent doesn't go astray, and only intervening when there is some architectural judgment that can best be handled by a human. The other is working most of an average week using a hacked-together piece of code, only autofilling a bit with an AI tool because their company's has been too long or too sensitive to leave in an agent's hands. Business card same title. Not much in common on a Tuesday afternoon.&lt;/p&gt;

&lt;p&gt;Now flip it around. You might have two people with the titles "AI orchestrator" and "developer" who are essentially doing the same job: writing specs, reading the generated output, and making the same judgment calls about what to accept or reject. One of these works somewhere that changed the job title to make it more interesting for a hiring page.&lt;/p&gt;

&lt;p&gt;Or take the third scenario – this one may be the weirdest of all: two people with the same role, the same company, the same team, and the same views on the tools – it is that different. One engineer handles all the planning and scaffolding, most of the testing, and spends the day reviewing and steering. Because there's a teammate next to them who has the same title, same manager, same sprint board and that teammate doesn't trust the agent's judgement about anything that involves a part of the system that he or she cares about, the teammate by his side, who has the same title and the same manager and the same sprint board, writes most of their code by hand. There were no special assignments for them. They simply slipped into various interpretations of the same character, and both are correct.&lt;/p&gt;

&lt;h2&gt;
  
  
  Explain the reasons behind this happening now and not at another time.
&lt;/h2&gt;

&lt;p&gt;This is not just a case of title inflation, but a reflection of what’s actually on the job – the job description is changing faster than the words used. HR job descriptions are rewritten every year, industry surveys are done, lists of "top skills for 2026" are compiled, and all that type of language is written and rewritten every year. The work is in constant flux, changing every few months. What you have is a huge disconnect between the label on the job and the experiences in the job, and people take different approaches based on the most recent reading they did, whether it's a conference talk or a LinkedIn post. No one is lying; they just don't have the right vocabulary for something that isn't settled yet.&lt;/p&gt;

&lt;p&gt;It's likely that this one will pass in a year or two when the dust settles, and once or twice, everyone just gave up on trying to figure it out, like with full-stack developer. We're in the messy middle right now; given the title of this blog, you'd think you know very little about what these guys do all day, which is why hiring, job-hunting, and even talking to another developer at a meetup becomes weirdly difficult.&lt;/p&gt;

&lt;h2&gt;
  
  
  Let me know your true mismatch
&lt;/h2&gt;

&lt;p&gt;Here's what I want you to do: leave your polished LinkedIn profile behind. What exactly was your position, and what did you spend most of your hours on this week? If I had to wager real cash, I would say all the way up to a good part of y'all reading this, those two answers don't even have a thing in common. Perhaps you're an engineer, and the vast majority of your week was spent on spec writing and review. Perhaps the title included "AI," and your week resembled the old way of life you were developing five years ago. I feel like it's going to be funnier and more exposing than either of us would expect, at least in the comments, which are the gap between the two.&lt;/p&gt;

&lt;p&gt;After all, isn't it a bit silly that, in a field this focused on accuracy, we can't even get a consensus on what we all do every day?&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Vibe Coding Didn't Kill Junior Devs' Careers. It Just Fast-Forwarded Them.</title>
      <dc:creator>Frihk Ian</dc:creator>
      <pubDate>Wed, 29 Jul 2026 13:07:36 +0000</pubDate>
      <link>https://dev.to/frihk_ian/vibe-coding-didnt-kill-junior-devs-careers-it-just-fast-forwarded-them-229p</link>
      <guid>https://dev.to/frihk_ian/vibe-coding-didnt-kill-junior-devs-careers-it-just-fast-forwarded-them-229p</guid>
      <description>&lt;p&gt;What was originally a joke, a colloquial term for projects that are done on the weekend, in which you tell a model what you want to do, don't read what it tells you, and follow it by feeling. It was completely out of that "hole" by 2026. &lt;a href="https://keyholesoftware.com/vibe-coding-trends-2026/" rel="noopener noreferrer"&gt;Ninety-two per cent of U.S. developers are using AI coding tools daily, up 340% from the year before&lt;/a&gt;, and a growing number of junior developers built their entire portfolio around it, since it allowed them to deliver something impressive without having to go through college and years of fundamental coding.&lt;br&gt;
That remained for a time. Next, it was time for the bill.&lt;/p&gt;

&lt;h2&gt;
  
  
  The surging demand for hiring that no one anticipated.
&lt;/h2&gt;

&lt;p&gt;Vibe coding isn't only a coding style; it's an economic change. &lt;a href="https://keyholesoftware.com/vibe-coding-trends-2026/" rel="noopener noreferrer"&gt;25% of startups in Y Combinator's Winter 2025 batch had codebases that are 95% or more AI-generated&lt;/a&gt;. &lt;a href="https://keyholesoftware.com/vibe-coding-trends-2026/" rel="noopener noreferrer"&gt;The price of developing a viable SaaS product has come down from $200,000 to $5,000, and the time to build is now six weeks versus six months&lt;/a&gt;. In that same context, a junior developer who can truthfully boast, "I built this whole app myself using AI" seems like a brilliant hire, both cheap and fast and able to deliver a complete product with just one developer.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://keyholesoftware.com/vibe-coding-trends-2026/" rel="noopener noreferrer"&gt;63% of today's coding users describe themselves as non-developers, product managers, marketing directors, founders, designers&lt;/a&gt;. &lt;a href="https://keyholesoftware.com/vibe-coding-trends-2026/" rel="noopener noreferrer"&gt;Forrester reckons that there are currently more than 16 million active citizen developers in the world&lt;/a&gt;, and &lt;a href="https://keyholesoftware.com/vibe-coding-trends-2026/" rel="noopener noreferrer"&gt;Gartner foresees the number of citizen developers will surpass the number of professional engineers by four to one by 2028&lt;/a&gt;. For a hot minute, it was really just "junior developer" or "person who could prompt well", and hiring managers went for whoever could get the demo packaged out the quickest.&lt;/p&gt;

&lt;h2&gt;
  
  
  Next, the codebases had to be tested!
&lt;/h2&gt;

&lt;p&gt;All this has a productivity understory that isn't as easy as the pitch makes it sound. &lt;a href="https://keyholesoftware.com/vibe-coding-trends-2026/" rel="noopener noreferrer"&gt;In a controlled study, METR determined that more experienced developers who worked on large, actual codebases were 19% slower when using AI tools, and also felt they were 20% faster&lt;/a&gt;. &lt;a href="https://keyholesoftware.com/vibe-coding-trends-2026/" rel="noopener noreferrer"&gt;Almost 40 points between how fast people feel and how fast they actually are&lt;/a&gt;, and that's important in that it really means that the teams that are planning sprints based on their self-reported productivity are doing it quietly on the sidelines.&lt;/p&gt;

&lt;p&gt;The same can be said for quality. &lt;a href="https://keyholesoftware.com/vibe-coding-trends-2026/" rel="noopener noreferrer"&gt;In one prominent study, the rate of bugs increased by 41% post AI coding tool adoption&lt;/a&gt;, while &lt;a href="https://keyholesoftware.com/vibe-coding-trends-2026/" rel="noopener noreferrer"&gt;other research comparing AI-coauthored pull requests with those written by humans revealed 1.7 times more major issues, with logic errors up 75% and readability issues tripling&lt;/a&gt;. However, &lt;a href="https://keyholesoftware.com/vibe-coding-trends-2026/" rel="noopener noreferrer"&gt;the less glamorous part of code, that which is refactored and simplified, dropped from a quarter of changed code in 2021 to under ten per cent by 2024&lt;/a&gt;, even as the amount of code being shipped kept climbing. This doesn't appear on day one. &lt;a href="https://keyholesoftware.com/vibe-coding-trends-2026/" rel="noopener noreferrer"&gt;It emerged by the 12th week, when teams are usually using 20-30% of their sprints to repair bugs they weren't fully aware of when they were first created by AI code&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;That's the reason why junior developers are the first to take the hit. Still, debugging doesn't involve writing code; it involves understanding code, and that's something that vibe coding allows you to avoid. A developer can develop a working feature and never, ever have a mental model of why it works, and that's okay until it doesn't and there's no foundation under them. Add security to the mix, and you'll find that &lt;a href="https://keyholesoftware.com/vibe-coding-trends-2026/" rel="noopener noreferrer"&gt;almost half of all code generated by AI fails basic industry security standards&lt;/a&gt;, and that &lt;a href="https://keyholesoftware.com/vibe-coding-trends-2026/" rel="noopener noreferrer"&gt;one study of more than 200 applications coded by vibe reveals that over 90 per cent had one or more vulnerabilities stemming from a lack of awareness of what they don't know&lt;/a&gt;. These are not fancy bugs, but the very basic ones: unvalidated input, lack of access controls, exposure of credentials, all of that sort of thing that an experienced engineer instinctively looks for, and a junior developer who didn't get the rudiments of engineering basics.&lt;/p&gt;

&lt;p&gt;There is no uncertainty about the production failures. &lt;a href="https://keyholesoftware.com/vibe-coding-trends-2026/" rel="noopener noreferrer"&gt;One vibe-coding tool experienced three separate security incidents which were widely covered, including one that remained open for 48 days&lt;/a&gt;. In another case, &lt;a href="https://keyholesoftware.com/vibe-coding-trends-2026/" rel="noopener noreferrer"&gt;an AI-powered social app took just three days to leak 1.5 million authentication tokens and 35,000 emails&lt;/a&gt;. On the broader market, &lt;a href="https://keyholesoftware.com/vibe-coding-trends-2026/" rel="noopener noreferrer"&gt;about ten thousand startups have tried to work out a working production application using an AI assistant, and over eight thousand of them need costly rebuilds that are usually $50,000 to $500,000 a pop&lt;/a&gt;, because the demo they would build wasn't going to hold up with actual users, actual load, and an actual security audit.&lt;/p&gt;

&lt;h2&gt;
  
  
  The market took no notice of this,
&lt;/h2&gt;

&lt;p&gt;As developers have incorporated these tools into their workflows, they are also becoming more sceptical about their effectiveness. Developers' own trust in the tools has been shaken as they have used them more. &lt;a href="https://keyholesoftware.com/vibe-coding-trends-2026/" rel="noopener noreferrer"&gt;Trust has dropped from approximately 40% two years ago to approximately 29% today, and almost half of developers actively distrust the output of AI-generated code&lt;/a&gt;. &lt;a href="https://keyholesoftware.com/vibe-coding-trends-2026/" rel="noopener noreferrer"&gt;Only a small number of senior engineers say they have high trust, and one in five say they have high distrust among senior engineers specifically&lt;/a&gt;. But &lt;a href="https://keyholesoftware.com/vibe-coding-trends-2026/" rel="noopener noreferrer"&gt;less than half of developers claim to always look over AI-generated code before committing it&lt;/a&gt;, meaning that plenty of AI-generated code is flying the flag without a second glance.&lt;/p&gt;

&lt;p&gt;Labour statistics are now catching up with the anecdotes. Overall demand for engineering talent hasn't gone away, but &lt;a href="https://keyholesoftware.com/vibe-coding-trends-2026/" rel="noopener noreferrer"&gt;junior developer hiring has dropped by almost 20% among those who would typically begin their careers in this role&lt;/a&gt;. &lt;a href="https://keyholesoftware.com/vibe-coding-trends-2026/" rel="noopener noreferrer"&gt;As much as forty to seventy per cent of the traditional entry-level development has been swallowed up by AI&lt;/a&gt;. Meanwhile, junior developers, who are seeking to enter the field, are doing so in one of the most competitive fields in years, and at the bare entry-level, in a field that increasingly demands the judgment of a senior engineer.&lt;/p&gt;

&lt;p&gt;The irony is sharp. The idea of vibe coding was to make it the leveller, the one thing that anyone could do and be a builder. For a certain group of junior coders, however, it was a way to an appointment and a quick path out of it, since the skills used to land that job didn't necessarily help when it came time to interact with real people, real traffic, real security audits.&lt;/p&gt;

&lt;p&gt;What really makes the difference between the ones who make it and those that don't?&lt;/p&gt;

&lt;p&gt;The organisations and developers that will emerge from this cycle without issues are not ones that eschewed AI but rather embraced it as an aid to real understanding, not a replacement. The pattern that passes this test is more "let me build with AI" than "let AI build it for me," with the caveat that while the AI is allowed to build it, there is a human in charge of checking each step it takes when the code is written into production code, the AI doesn't run the test gates unless there is a deadline pressure that can't be overcome, and the specifications are detailed enough for an agent to know exactly what is supposed to be built, and not just handed an open-ended prompt and encouraged to guess well. Such teams are consistently spared the technical debt and exposure to security issues that plague other teams that scale up their use of AI without first establishing that structure. If teams consider governance as something to do afterwards, they are almost always going to pay for it afterwards at multiple times the cost of doing it from the beginning.&lt;/p&gt;

&lt;p&gt;Vibe coding doesn't need to be abandoned, and it shouldn't. If you're a junior developer trying to land a job right now, the pitch that lands you the job and keeps you on is NOT "I can have AI create things." It's &lt;strong&gt;"I know how it works well enough to fix it when it breaks, secure it before it ships, and explain it to the next person who touches it."&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>vibecoding</category>
      <category>juniordev</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Multiagent orchestration article</title>
      <dc:creator>Frihk Ian</dc:creator>
      <pubDate>Tue, 28 Jul 2026 08:38:11 +0000</pubDate>
      <link>https://dev.to/frihk_ian/multiagent-orchestration-article-e15</link>
      <guid>https://dev.to/frihk_ian/multiagent-orchestration-article-e15</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9p3h9ltv29kcdhgp372v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9p3h9ltv29kcdhgp372v.png" alt=" " width="799" height="475"&gt;&lt;/a&gt;Multi-agent orchestration is the hot topic of 2026. Introduced in February, &lt;a href="https://dev.to/jpeggdev/the-ai-revolution-in-2026-top-trends-every-developer-should-know-18eb"&gt;Agent HQ from GitHub allows developers to concurrently use Claude, Codex, and Copilot to solve a problem, with each having a different perspective on trade-offs or details&lt;/a&gt;. &lt;a href="https://dev.to/jpeggdev/the-ai-revolution-in-2026-top-trends-every-developer-should-know-18eb"&gt;Between Q1 2024 and Q2 2025, Gartner experienced a 1,445% increase in inquiries about multi-agent systems&lt;/a&gt;. Steve Yegge, a very experienced engineer at Amazon and Google, has discussed his work on orchestrated agents and &lt;a href="https://mikemason.ca/writing/ai-coding-agents-jan-2026/" rel="noopener noreferrer"&gt;producing 12,000 lines of code per day&lt;/a&gt;. Even more impressively, &lt;a href="https://mikemason.ca/writing/ai-coding-agents-jan-2026/" rel="noopener noreferrer"&gt;Cursor's team programmed an entire browser over a thousand files and a million lines of code in just one week by using hierarchical orchestration rather than having a single agent perform all the tasks sequentially&lt;/a&gt;, though &lt;a href="https://mikemason.ca/writing/ai-coding-agents-jan-2026/" rel="noopener noreferrer"&gt;multiple reviewers reported the code didn't compile at announcement, and Cursor's own CEO described the result as merely "kind of works"&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The part nobody's celebrating&lt;/p&gt;

&lt;p&gt;The only news to this is Google's 2025 DORA report. It determined that &lt;a href="https://mikemason.ca/writing/ai-coding-agents-jan-2026/" rel="noopener noreferrer"&gt;for a 90% increase in AI adoption, bug rates climbed 9%, code review time rose 91%, and average PR size grew 154%&lt;/a&gt;. When read as a single group, that pattern emerges instantly: teams are shipping more code, more quickly, and it's measurably more difficult to review, and measurably more buggy once it is shipped. No, multi-agent setups don't help with this; they exacerbate it. You're not just reading one model's decisions now; you're reading several.&lt;/p&gt;

&lt;p&gt;Engineers who interact with such systems refer to a particular type of failure: &lt;a href="https://mikemason.ca/writing/ai-coding-agents-jan-2026/" rel="noopener noreferrer"&gt;architectural drift, in which each agent takes an action that is locally optimal but inconsistent with the actions taken by the other agents five minutes ago&lt;/a&gt;. One agent selects one pattern to use for errors, another agent selects another pattern for a neighboring module, and nobody realizes until anybody attempts to extend the feature, and the codebase spits. Then there is the issue of &lt;a href="https://mikemason.ca/writing/ai-coding-agents-jan-2026/" rel="noopener noreferrer"&gt;"lost in the middle," as it's called, and how much information that is in the middle of the long context window becomes lost and essentially forgotten by the agent&lt;/a&gt;, so it seems like it doesn't know about it.&lt;/p&gt;

&lt;p&gt;The naive version of this doesn't work very well, as Cursor's own account of constructing that browser admits. &lt;a href="https://mikemason.ca/writing/ai-coding-agents-jan-2026/" rel="noopener noreferrer"&gt;The first tried to treat all agents the same and, to avoid collisions, used file locking, but this didn't work: agents were holding locks too long, and twenty agents were operating at the throughput of two or three. Their second attempt was optimistic concurrency control, not locks, and that didn't work out quite right; the agents became more of a risk taker and began to avoid anything that resembled a hard task&lt;/a&gt;. &lt;a href="https://mikemason.ca/writing/ai-coding-agents-jan-2026/" rel="noopener noreferrer"&gt;What really worked was a hierarchical structure as opposed to agents being free to improvise in parallel: Planner agents that continuously explored the codebase and created tasks, Worker agents that executed assigned tasks without coordinating with each other, and Judge agents that determined whether to continue at each cycle's end&lt;/a&gt;, rather than a bunch of agents improvising freely in parallel with no one peeking at each other's work.&lt;/p&gt;

&lt;p&gt;Why this becomes a review nightmare&lt;/p&gt;

&lt;p&gt;In response, automated PR review tools have scaled, and &lt;a href="https://zylos.ai/research/2026-04-22-autonomous-code-review-multi-agent-pr-analysis/" rel="noopener noreferrer"&gt;teams managing multiple agent review fleets see real improvements: 30–60% faster review cycle times and, in the best cases, 25–35% fewer production defects&lt;/a&gt;. But even the researchers developing these systems are straightforward about the problem: AI reviewers are good at spotting issues in the code, and they're not so good at understanding what you were trying to accomplish, and why you were making the decision. What you get is a ton of automated "this could be improved" comments, yet not much of "this doesn't fit how the rest of the system thinks.&lt;/p&gt;

&lt;p&gt;In a piece about orchestrated coding, Addy Osmani stated it quite simply: &lt;a href="https://addyosmani.com/blog/code-agent-orchestra/" rel="noopener noreferrer"&gt;"With an orchestrated army of agents, there's no natural bottleneck. Small harmless mistakes — a code smell here, a duplication there, an unnecessary abstraction — compound at a rate that's unsustainable."&lt;/a&gt; These are no longer being created by a single human who was used to writing the code manually and would have noticed any errors or bugs; now they are just being created by many humans who are not involved in the code change, so the errors just accumulate. There is no crash reported. It turns up when someone tries to add a feature to it, and finds the architecture won't support it, and the tests that the agents also wrote are no more reliable than the code they were supposed to be checking.&lt;/p&gt;

&lt;p&gt;What this actually means for teams adopting this now&lt;/p&gt;

&lt;p&gt;None of this is a reason to not use multi-agent coding. The productivity narrative is true, and it will keep going. But it is the teams who are designing plan-approval steps, token budgets, verifier agents, human review gates, and so on into their orchestration, rather than eliminating themselves from the equation and hoping that the agents will get it and do this well. These teams will not realise the cost right away if they do not do that. They will see it in 6 months when the two-line feature request becomes a two-week rewrite, and no one, human or agent, understands the system's structure and why.&lt;/p&gt;

&lt;p&gt;There was never a problem with speed. It was inevitable that coordination would be difficult. But it was not until now that we needed to solve it.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Nobody's Reading Tutorials Anymore. They're Just Asking AI.</title>
      <dc:creator>Frihk Ian</dc:creator>
      <pubDate>Mon, 27 Jul 2026 00:52:47 +0000</pubDate>
      <link>https://dev.to/frihk_ian/nobodys-reading-tutorials-anymore-theyre-just-asking-ai-17nc</link>
      <guid>https://dev.to/frihk_ian/nobodys-reading-tutorials-anymore-theyre-just-asking-ai-17nc</guid>
      <description>&lt;p&gt;Two or three months ago, I noticed that my Go tutorials were not receiving the level of engagement I was expecting, with fewer comments and saved posts. The first thing that popped into my mind was that I was slipping. Then I absorbed the larger data, and it seems this isn't a me problem; this is an industry problem.&lt;/p&gt;

&lt;p&gt;The figures are appalling.&lt;/p&gt;

&lt;p&gt;Begin on Stack Overflow, which was the most comprehensive reference library for technology. During 2014 to 2020 Question volume reached a maximum of over 2,00,000 per month. It ended up below 50,000 already in late 2025, wiping out 15 years of increases. &lt;a href="https://ppc.land/stack-overflow-traffic-collapses-as-ai-tools-reshape-how-developers-code/" rel="noopener noreferrer"&gt;A January 2026 data visualization, built from Stack Overflow's own Data Explorer, showed the platform's monthly question volume had fallen back to roughly what it was in 2008, the year the site launched&lt;/a&gt;. The same 2025 Developer Survey found that &lt;a href="https://ppc.land/stack-overflow-traffic-collapses-as-ai-tools-reshape-how-developers-code/" rel="noopener noreferrer"&gt;while 82% of respondents still visit Stack Overflow at least a few times a month, only 25% do so daily or more often&lt;/a&gt;, a shift from the platform's old status as a daily habit for most programmers.&lt;/p&gt;

&lt;p&gt;It's not just one platform which is in trouble. Invisible, though, is the larger behaviour change, one that goes beyond the visible symptom, namely that developers no longer consult written references first.&lt;/p&gt;

&lt;p&gt;Rather than "Where everybody was," here is "Where everyone went.&lt;/p&gt;

&lt;p&gt;They went to AI. In the past, this was a rarity, no longer the exception. &lt;a href="https://uvik.net/blog/ai-coding-assistant-statistics/" rel="noopener noreferrer"&gt;Approximately 84% (up from 76% a year ago) of all developers use or plan to use AI coding tools, according to an AI Coding Assistant survey Stack Overflow conducted this year&lt;/a&gt;. Developers report being most comfortable turning to AI for tasks like searching for answers, learning new concepts, and writing documentation, and &lt;a href="https://uvik.net/blog/ai-coding-assistant-statistics/" rel="noopener noreferrer"&gt;44% of developers now use AI tools to learn to code, up from 37% the year before&lt;/a&gt;. Interestingly enough, when developers are asked what their favourite tools of the art are best at, "creating documentation" and "explaining any existing code" are near the top of the list, ahead of "writing new code from scratch.&lt;/p&gt;

&lt;p&gt;The final one is worthy of contemplation: developers are increasingly turning to AI to explain a concept rather than write plain, original code for them. That's right, a direct miss on everything that the tutorial does at its core, which is explaining.&lt;/p&gt;

&lt;p&gt;No wonder, it's not that difficult! The tutorial is geared to the "average reader" (as it's called). A question is directly written for you right now with your stack trace, your file, your specific stupid typo. No pages of preamble to scroll through to discover just one line of config that you needed, no "Closed as duplicate" and no ads, just an answer tuned to your exact problem.&lt;/p&gt;

&lt;p&gt;However, this doesn't seem to be a clean sweep for AI.&lt;/p&gt;

&lt;p&gt;And this is where it gets more interesting than 'AI beat tutorials, tutorials are dead!'. Usage is on the increase, but trust is not. &lt;a href="https://theaieconomy.substack.com/p/stack-overflow-2025-ai-trust-gap" rel="noopener noreferrer"&gt;Some 46% lack confidence in the accuracy of AI-generated output, up from 31% a year ago, and nearly two-thirds feel AI frequently generates code that seems correct but isn't necessarily reliable&lt;/a&gt;. In fact, &lt;a href="https://www.secondtalent.com/resources/ai-developer-productivity-tools-2026/" rel="noopener noreferrer"&gt;according to research from METR, seasoned developers actually took 19% longer to accomplish their tasks using AI tools; however, they felt they finished 20% faster after completing the work&lt;/a&gt;. There is definitely an overestimation of how much AI is actually supporting people.&lt;/p&gt;

&lt;p&gt;An even more acute concern is piling up regarding junior developers. They do not develop the predispositions they need when they rely on AI to solve their problems rather than on docs and forums. They can possibly write working code without knowing how it works, which is okay up until the moment the AI goes off-track by making a minor mistake that it finds hard to track in the code; at that point, they don't have a solid base to lean on if it goes astray.&lt;/p&gt;

&lt;p&gt;It is not a matter of "tutorials stink, AI is good. It's that developers have settled on a path that's more time-consuming and difficult, and that offers the chance to develop real comprehension, rather than a quicker way that yields an answer with little assurance it's correct.&lt;/p&gt;

&lt;p&gt;Popular lessons can be seen when you write tutorials. Writing tutorials will show some of the popular lessons.&lt;/p&gt;

&lt;p&gt;This is not that it is time to halt its development; it's just that it's time to modify what you write and how. Generic explanation/memorized text is strong, with the notable exception of gotchas or "why this worked last month, and not now", explaining architectural trade-offs is strong, but nothing concerning a fast-changing library or a particular corner case is strong. Well, that's where a good article still gets its power from. It also helps when you are aware of the fact that unless the AI does an excellent job with their answer, your reader is not coming to your post cold, rather they are here because they want to take a look at it to see if it matches their requirements and/or sanity, so if you write assuming they came to your post because the AI answer did not suffice, it will benefit more than an answer they are reaching for from cold.&lt;/p&gt;

&lt;p&gt;Optimise for skimmability and machine-readability as well, because these days there's a decent portion of traffic that's not coming to you from a human who's reading from top to bottom, but rather there's a machine there reading your page to respond to the query of someone else. Headings, explicit statements of code, and clear explanations benefit both the writer and the reader. Finally, don't forget to be more specific about the "why" rather than the "how" — it's the one thing that thin AI answers so rarely but the most crucial part of what junior developers need and the part that will keep a human reader on your page.&lt;/p&gt;

&lt;p&gt;What direction this is taking&lt;/p&gt;

&lt;p&gt;I don't know why, but tutorials don't just disappear. I don't think the form that dies is a particularly useful way to get X configured, since there's a much simpler prompt that does the job more easily. The things that remain, perhaps even grow, are the pieces of writing that convey judgment, negotiation, nuance, and detail that have not yet been fully captured through modelling.&lt;/p&gt;

&lt;p&gt;So was the love for reading changed. It wasn't until somebody "got it" that the need for someone who actually understood the problem.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Array in Go</title>
      <dc:creator>Frihk Ian</dc:creator>
      <pubDate>Wed, 24 Jun 2026 09:33:49 +0000</pubDate>
      <link>https://dev.to/frihk_ian/array-in-go-mad</link>
      <guid>https://dev.to/frihk_ian/array-in-go-mad</guid>
      <description>&lt;h2&gt;
  
  
  What is an Array in Go?
&lt;/h2&gt;

&lt;p&gt;In Go, an array is a fixed-size, ordered set of values with the same type. Imagine an array as a 12 egg tray; the minimum number of eggs which can fit into an array is 12; the maximum number of eggs which can fit into an array is 12. That is the exact behaviour of a Go array.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;package&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;
&lt;span class="err"&gt;​&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="s"&gt;"fmt"&lt;/span&gt;
&lt;span class="err"&gt;​&lt;/span&gt;
&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

&lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;groceries&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;3&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="c"&gt;// Step 1: Create an array that holds 3 strings&lt;/span&gt;
&lt;span class="n"&gt;groceries&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Bread"&lt;/span&gt;&lt;span class="c"&gt;// Step 2: Put "Bread" in slot 0&lt;/span&gt;
&lt;span class="n"&gt;groceries&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Milk"&lt;/span&gt;&lt;span class="c"&gt;// Step 3: Put "Milk" in slot 1&lt;/span&gt;
&lt;span class="n"&gt;groceries&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Eggs"&lt;/span&gt;&lt;span class="c"&gt;// Step 4: Put "Eggs" in slot 2&lt;/span&gt;
&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;groceries&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="c"&gt;// Step 5: Print the whole array&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Expected output:&lt;br&gt;
&lt;code&gt;[Bread Milk Eggs]&lt;/code&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Zero Values
&lt;/h2&gt;

&lt;p&gt;In Go, you create an array by using the var keyword, and each of the slots receives the safe code Zero value, given that no elements are explicitly set.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ft65yo36zfwm91e9b82t7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ft65yo36zfwm91e9b82t7.png" alt=" " width="504" height="253"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This means that your array will never be in an unsafe state of being uninitialized. It will be valid on every slot, even before set. The same thing is a safety feature in Go intentionally.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;prices&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;3&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="kt"&gt;float64&lt;/span&gt;

&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;prices&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c"&gt;//  Output: [0 0 0]  - Go fills all the values with zeros automatically&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Declaring an Array
&lt;/h2&gt;

&lt;p&gt;In Go, you can declare an array in a few different ways, and you will learn about each of them in turn.&lt;/p&gt;

&lt;h4&gt;
  
  
  Using the var Declaration
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;groceries&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;3&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;
&lt;span class="n"&gt;groceries&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Bread"&lt;/span&gt;
&lt;span class="n"&gt;groceries&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Milk"&lt;/span&gt;
&lt;span class="n"&gt;groceries&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Eggs"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you want to initialise an array of a specific size and use it later, then this is the best method to achieve this.&lt;/p&gt;

&lt;h4&gt;
  
  
  Array Literals
&lt;/h4&gt;

&lt;p&gt;If you are already aware of all the values at the time you write the code, then you can use the literal syntax:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;package&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="s"&gt;"fmt"&lt;/span&gt;

&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="n"&gt;groceries&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;3&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"Bread"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Milk"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Eggs"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;groceries&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Expected output:&lt;br&gt;
&lt;code&gt;[Bread Milk Eggs]&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The actual syntax is:&lt;br&gt;
&lt;code&gt;[size]type{value1, value2, value3}&lt;/code&gt;&lt;br&gt;
This method is used when we know the values which we want to store in an array.&lt;/p&gt;
&lt;h4&gt;
  
  
  Let the Compiler count for you — The &lt;code&gt;...&lt;/code&gt; trick
&lt;/h4&gt;

&lt;p&gt;When using literal syntax, and you find that you have to manually count yourself, there's a shortcut in Go. Use ... to fill the size so the compiler can calculate the length automatically.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="n"&gt;groceries&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;...&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"Bread"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Milk"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Eggs"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Butter"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Coffee"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="c"&gt;//Three dots  compiler counts for you&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The type of groceries is [5]string. The ... instructs the compiler to count for you. This will be helpful if you have a super long list and you can't determine its length.&lt;/p&gt;

&lt;h4&gt;
  
  
  Sparse Initialization
&lt;/h4&gt;

&lt;p&gt;You can also use index: value syntax in the braces: to specify where a value will go:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;package&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;
&lt;span class="err"&gt;​&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="s"&gt;"fmt"&lt;/span&gt;
&lt;span class="err"&gt;​&lt;/span&gt;
&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="c"&gt;// Put "Bread" in slot 0 and "Coffee" in slot 4; all other slots get ""&lt;/span&gt;
&lt;span class="n"&gt;groceries&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;5&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Bread"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;4&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Coffee"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;groceries&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;​&lt;br&gt;
Expected output:&lt;br&gt;
&lt;code&gt;[Bread Coffee]&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This is helpful when you have an array of a large number of elements, but just a couple of elements to change.&lt;/p&gt;
&lt;h2&gt;
  
  
  How to access elements and modify an array.
&lt;/h2&gt;

&lt;p&gt;Each element of an array is retrieved by the array name and an index number enclosed in square brackets.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;package&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="s"&gt;"fmt"&lt;/span&gt;

&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

&lt;span class="n"&gt;groceries&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;3&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"Bread"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Milk"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Eggs"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;For&lt;/span&gt; &lt;span class="n"&gt;each&lt;/span&gt; &lt;span class="n"&gt;element&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;read&lt;/span&gt; &lt;span class="n"&gt;it&lt;/span&gt; &lt;span class="n"&gt;on&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;screen&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; 
&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;groceries&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;&lt;span class="c"&gt;// Read "Bread" on the screen&lt;/span&gt;
&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;groceries&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;&lt;span class="c"&gt;// Read slot 2: Eggs&lt;/span&gt;
&lt;span class="n"&gt;groceries&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Brown Bread"&lt;/span&gt; &lt;span class="c"&gt;// Change the value of the 0th element of the array.&lt;/span&gt;
&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;groceries&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;&lt;span class="c"&gt;// Read slot 0 again → "Brown Bread"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Expected output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Bread
Eggs
Brown Bread
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  What are the consequences of going beyond the lines?
&lt;/h4&gt;

&lt;p&gt;If you try to access a non-existent part of a structure (for example, groceries[5] for a 3-element array), then Go will immediately exit the program with a runtime panic:&lt;br&gt;
runtime error: index out of range [5] with length 3&lt;br&gt;
Not a silent bug this time. Go lets you know what was amiss. len(array) - 1 is the final valid index in the array.&lt;/p&gt;
&lt;h2&gt;
  
  
  Getting the Length with len()
&lt;/h2&gt;

&lt;p&gt;len() returns the size (number of slots) of an array:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;package&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="s"&gt;"fmt"&lt;/span&gt;

&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="n"&gt;groceries&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;5&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"Bread"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Milk"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Eggs"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Butter"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Coffee"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Items on list:"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;groceries&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Expected output:&lt;br&gt;
&lt;code&gt;Items on list: 5&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;If an array is declared with a size, then len() always returns the exact size, irrespective of whether there are values stored in some of the array's slots. An array is always the size that it was created to be.&lt;/p&gt;

&lt;p&gt;Also, there is an operation cap(), which is called "capacity". Arrays cannot be lengthened or shortened, but the two functions, cap() and len(), return the same value. Use len(arr) instead of literals for the size.  If you ever change the array declaration, len() adjusts automatically.&lt;/p&gt;

&lt;p&gt;When the array is of length, len() always returns the size (independent of whether or not there are zeroes in the array). An array is always allocated the memory space it was declared to have.&lt;/p&gt;
&lt;h2&gt;
  
  
  Arrays are valued, not references.
&lt;/h2&gt;

&lt;p&gt;As a result of Go's copy behavior on assigning an array to a new variable, the entire array is copied. There are two independent variables – if one changes, the other one definitely will not change at all. Let's say we think of an example;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;package&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;
&lt;span class="err"&gt;​&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="s"&gt;"fmt"&lt;/span&gt;
&lt;span class="err"&gt;​&lt;/span&gt;
&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="n"&gt;groceries&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;3&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"Bread"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Milk"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Eggs"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="n"&gt;backup&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;groceries&lt;/span&gt;&lt;span class="c"&gt;// This copies ALL of groceries into backup&lt;/span&gt;
&lt;span class="err"&gt;​&lt;/span&gt;
&lt;span class="n"&gt;groceries&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Brown Bread"&lt;/span&gt;&lt;span class="c"&gt;// Change the original&lt;/span&gt;
&lt;span class="err"&gt;​&lt;/span&gt;
&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"groceries:"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;groceries&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"backup:"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;backup&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;​&lt;br&gt;
Expected output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;groceries: [Brown Bread Milk Eggs]
backup:[Bread Milk Eggs]

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above shows that despite replacing groceries [0] with ‘Brown Bread’, backup was not affected. This is similar to photocopying your shopping list! After they've made the photocopy, it remains unchanged if they write on the original. They started identical, but are now two completely separate pieces of paper.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sharing With Pointers
&lt;/h2&gt;

&lt;p&gt;If we want, the changes that we make with our new variable to affect the original array, it's using a pointer.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;package&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;
&lt;span class="err"&gt;​&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="s"&gt;"fmt"&lt;/span&gt;
&lt;span class="err"&gt;​&lt;/span&gt;
&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="n"&gt;groceries&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;3&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"Bread"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Milk"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Eggs"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="n"&gt;shared&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;groceries&lt;/span&gt;&lt;span class="c"&gt;// &amp;amp; means "give me the address of groceries"&lt;/span&gt;
&lt;span class="err"&gt;​&lt;/span&gt;
&lt;span class="n"&gt;groceries&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Brown Bread"&lt;/span&gt;
&lt;span class="err"&gt;​&lt;/span&gt;
&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"groceries:"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;groceries&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"shared:"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;shared&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="c"&gt;// * means "follow the pointer to the value"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;​&lt;br&gt;
Expected output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;groceries: [Brown Bread Milk Eggs]
shared:[Brown Bread Milk Eggs]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&amp;amp;groceries make a pointer. You don't copy the array; you copy a small "address" indicating where the array is stored in memory. That is followed by the word ‘*shared follows that address to get the actual value. When Shared access is needed, Pointers are used. In most situations, you'll opt for the default copy behaviour, which is more secure and easier to do.&lt;/p&gt;

&lt;h2&gt;
  
  
  Comparing Arrays
&lt;/h2&gt;

&lt;p&gt;Go and share how you can use “==” and “!=” to compare two arrays of equal “size” and “type”.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;package&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;
&lt;span class="err"&gt;​&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="s"&gt;"fmt"&lt;/span&gt;
&lt;span class="err"&gt;​&lt;/span&gt;
&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="n"&gt;list1&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;3&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"Bread"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Milk"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Eggs"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="n"&gt;list2&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;3&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"Bread"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Milk"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Eggs"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="n"&gt;list3&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;3&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"Bread"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Milk"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Coffee"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="err"&gt;​&lt;/span&gt;
&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Same?"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;list1&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;list2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="c"&gt;// true&lt;/span&gt;
&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Same?"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;list1&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;list3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="c"&gt;// false&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;​&lt;br&gt;
Expected output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Same? true
Same? false

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two arrays are equal if they are of the same type and length and the elements of the arrays in the corresponding positions are all equal. You must have both conditions.&lt;br&gt;
Comparison of differently sized arrays is not possible. The compiler will halt you, since they are of different types.&lt;/p&gt;

&lt;p&gt;Looping Through Arrays&lt;br&gt;
For small arrays, manually writing the below would work: &lt;code&gt;groceries[0], groceries[1], groceries[2]&lt;/code&gt;. Anything larger, you just use a loop to visit each element by itself. Some of the loops you can use to accomplish this are listed here:&lt;/p&gt;
&lt;h4&gt;
  
  
  The for range Loop
&lt;/h4&gt;

&lt;p&gt;The most popular looping over an array in Go is the following for range loop:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;package&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="s"&gt;"fmt"&lt;/span&gt;
&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="n"&gt;groceries&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;5&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"Bread"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Milk"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Eggs"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Butter"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Coffee"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="n"&gt;For&lt;/span&gt; &lt;span class="n"&gt;each&lt;/span&gt; &lt;span class="n"&gt;element&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;in&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;groceries&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Index: "&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s"&gt;" Item: "&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Expected output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Index: 0 Item: Bread
Index: 1 Item: Milk
Index: 2 Item: Eggs
Index: 3 Item: Butter
Index: 4 Item: Coffee
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The index will contain the number of the slot that is being modified on each iteration through the loop, and the item will contain a copy of the element being modified. The loop stops by itself when it runs out of elements. No more worrying about out of bounds.&lt;/p&gt;

&lt;p&gt;In Go programming, all the variables defined must be used. The for-range loop provides Go with two variables in its "for" clause: the index and element variable. If the index isn’t useful  to you, then you can't just leave it there intact. It will refuse to compile with Go.&lt;/p&gt;

&lt;p&gt;This is where the blank identifier &lt;code&gt;_&lt;/code&gt; is introduced. It is Go's way of letting you say, "I know this value exists, but I am deliberately throwing it away."&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;package&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;
&lt;span class="err"&gt;​&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="s"&gt;"fmt"&lt;/span&gt;
&lt;span class="err"&gt;​&lt;/span&gt;
&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="n"&gt;groceries&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;5&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"Bread"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Milk"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Eggs"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Butter"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Coffee"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="err"&gt;​&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="k"&gt;range&lt;/span&gt; &lt;span class="n"&gt;groceries&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Item:"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Expected output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Item: Bread
Item: Milk
Item: Eggs
Item: Butter
Item: Coffee
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It's also possible to discard the value and keep the index. If so, simply do not use the second variable at all:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="n"&gt;For&lt;/span&gt; &lt;span class="n"&gt;each&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt; &lt;span class="n"&gt;in&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;groceries&lt;/span&gt; &lt;span class="n"&gt;array&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Index:"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  A classic  for Loop.
&lt;/h4&gt;

&lt;p&gt;In the case where you require more control, such as when going in reverse or skipping an element, the classic counter-based for loop is best:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;package&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;
&lt;span class="err"&gt;​&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="s"&gt;"fmt"&lt;/span&gt;
&lt;span class="err"&gt;​&lt;/span&gt;
&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="n"&gt;groceries&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;5&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"Bread"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Milk"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Eggs"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Butter"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Coffee"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="err"&gt;​&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;groceries&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Position"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"-&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;groceries&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;​&lt;br&gt;
Expected output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Position 0 -&amp;gt; Bread
Position 1 -&amp;gt; Milk
Position 2 -&amp;gt; Eggs
Position 3 -&amp;gt; Butter
Position 4 -&amp;gt; Coffee
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;​&lt;br&gt;
Iterating in reverse:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;groceries&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;--&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;groceries&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c"&gt;//`Output: Coffee → Butter → Eggs → Milk → Bread`&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Printing every other item:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;groceries&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;groceries&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c"&gt;//`Output: Bread → Eggs → Coffee (slots 0, 2, and 4)`&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Multi-Dimensional Arrays
&lt;/h2&gt;

&lt;p&gt;So far, all the arrays have been a single row of values (one-dimensional). Multi-dimensional arrays (arrays of arrays) are also supported in Go.&lt;br&gt;
The most common case is a 2D array, which is a grid or a table. For instance, if I go to the shops every week and make a plan for the items I want to buy by each day and area of the shop:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;package&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;
&lt;span class="err"&gt;​&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="s"&gt;"fmt"&lt;/span&gt;
&lt;span class="err"&gt;​&lt;/span&gt;
&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="c"&gt;// A 3-day plan with 2 items per day&lt;/span&gt;
&lt;span class="n"&gt;weeklyPlan&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;3&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"Bread"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Milk"&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="c"&gt;// Day 0&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"Eggs"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Butter"&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="c"&gt;// Day 1&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"Coffee"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Fruit"&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="c"&gt;// Day 2&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="err"&gt;​&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;day&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;items&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="k"&gt;range&lt;/span&gt; &lt;span class="n"&gt;weeklyPlan&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Day %d: %s and %s&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;day&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;items&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;items&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="n"&gt;Day&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Bread&lt;/span&gt; &lt;span class="n"&gt;and&lt;/span&gt; &lt;span class="n"&gt;Milk&lt;/span&gt;
&lt;span class="n"&gt;Day&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Eggs&lt;/span&gt; &lt;span class="n"&gt;and&lt;/span&gt; &lt;span class="n"&gt;Butter&lt;/span&gt;
&lt;span class="n"&gt;Day&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Coffee&lt;/span&gt; &lt;span class="n"&gt;and&lt;/span&gt; &lt;span class="n"&gt;Fruit&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;[3][2]string&lt;/code&gt;: An array of 3 elements, each of which is an array of 2 strings. The first index tells you which row to choose, the second index tells you which column to choose:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="n"&gt;weeklyPlan&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Bread"&lt;/span&gt;&lt;span class="c"&gt;// Day 0, first item&lt;/span&gt;
&lt;span class="n"&gt;weeklyPlan&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Milk"&lt;/span&gt;&lt;span class="c"&gt;// Day 0, second item&lt;/span&gt;
&lt;span class="n"&gt;weeklyPlan&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Fruit"&lt;/span&gt;&lt;span class="c"&gt;// Day 2, second item&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;An index position is needed to reference a particular cell, the first being the row index, and the second, the column index.&lt;br&gt;
passing an Array object to a function.&lt;br&gt;
In Go, an array passed to a function is itself a complete copy of the array; the function does not refer to the original array. Any changes the function makes don't affect the original:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;package&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;
&lt;span class="err"&gt;​&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="s"&gt;"fmt"&lt;/span&gt;
&lt;span class="err"&gt;​&lt;/span&gt;
&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;printAndModify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;list&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;3&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="n"&gt;list&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Changed"&lt;/span&gt;&lt;span class="c"&gt;// Modifies the LOCAL copy only&lt;/span&gt;
&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Inside:"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;list&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="err"&gt;​&lt;/span&gt;
&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="n"&gt;groceries&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;3&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"Bread"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Milk"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Eggs"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="n"&gt;printAndModify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;groceries&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Outside:"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;groceries&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="c"&gt;// Original is unchanged&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;​&lt;br&gt;
Expected output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Inside: [Changed Milk Eggs]
Outside: [Bread Milk Eggs]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The function takes a snapshot of an array that is independent of one another.&lt;br&gt;
If you have to change the original function, provide a pointer:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;package&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;
&lt;span class="err"&gt;​&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="s"&gt;"fmt"&lt;/span&gt;
&lt;span class="err"&gt;​&lt;/span&gt;
&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;updateFirstItem&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;list&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;3&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="n"&gt;list&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Brown Bread"&lt;/span&gt;&lt;span class="c"&gt;// This modifies the original&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="err"&gt;​&lt;/span&gt;
&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="n"&gt;groceries&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;3&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"Bread"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Milk"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Eggs"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="n"&gt;updateFirstItem&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;groceries&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Outside:"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;groceries&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="c"&gt;// Now the original IS changed&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;​&lt;br&gt;
Expected output:&lt;br&gt;
&lt;code&gt;Outside: [Brown Bread Milk Eggs]&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;If you have a large array greater than a few hundred elements, always use a pointer instead of copying to avoid the cost of the copy.&lt;/p&gt;
&lt;h2&gt;
  
  
  Limitations of Arrays
&lt;/h2&gt;

&lt;p&gt;Though concise and straightforward, arrays are restricted in their use and come with limitations that you'll hit hard soon.&lt;/p&gt;
&lt;h4&gt;
  
  
  The Size Is Fixed Forever
&lt;/h4&gt;

&lt;p&gt;After defining a [3]string, it will always contain exactly 3 strings, always! You can't add a fourth item. You can't remove one to shrink it. The size is baked in at compile time. If your shopping list grows to 6 items, your [5]string array can't help you.&lt;br&gt;
The array size can not be a variable, must be a literal number or named constant:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="m"&gt;5&lt;/span&gt;
&lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;groceries&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above is a compiler error because of the occurrence of the variable n.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="n"&gt;Fix&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;
&lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="m"&gt;5&lt;/span&gt;
&lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;groceries&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="c"&gt;// it Works, n is a constant&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This means you can't create an array whose size depends on something you only know at runtime, like how many items the user typed in. For that, you need a slice.&lt;/p&gt;

&lt;h4&gt;
  
  
  Passing Large Arrays Is Expensive
&lt;/h4&gt;

&lt;p&gt;Every function call copies the entire array. For a [10000]string, that is 10,000 strings copied just to call a function.&lt;br&gt;
Arrays of Different Sizes Are Incompatible Types&lt;br&gt;
A function that accepts [3] strings can't be called with a [5]string. You would need two separate functions with different signatures.&lt;br&gt;
&lt;code&gt;append()&lt;/code&gt; Does Not Work on Arrays&lt;br&gt;
&lt;code&gt;append()&lt;/code&gt; — the function that adds elements to a collection — only works on slices, not arrays:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="n"&gt;groceries&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;3&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"Bread"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Milk"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Eggs"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="n"&gt;groceries&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;groceries&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Butter"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="c"&gt;// Compiler `error`: append expects a slice&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;​&lt;br&gt;
These limitations are not bugs. Fixed-size value types are simple, predictable, and give the compiler strong guarantees. But most real-world programming needs something that can grow and shrink at runtime. That something is the slice.&lt;/p&gt;
&lt;h2&gt;
  
  
  Common Mistakes with Arrays
&lt;/h2&gt;
&lt;h4&gt;
  
  
  Mistake 1: Assigning Arrays of Different Sizes
&lt;/h4&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="n"&gt;list&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;3&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"Bread"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Milk"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Eggs"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;biggerList&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;4&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;list&lt;/span&gt;&lt;span class="c"&gt;//  Compiler `error` — different types&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;​&lt;br&gt;
Fix: make sure both arrays have the same size, or use a slice if you need flexibility.&lt;br&gt;
​&lt;/p&gt;
&lt;h4&gt;
  
  
  Mistake 2: Expecting Assignment to Share Data
&lt;/h4&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="n"&gt;list&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;3&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"Bread"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Milk"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Eggs"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="n"&gt;backup&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;list&lt;/span&gt;
&lt;span class="n"&gt;backup&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Brown Bread"&lt;/span&gt;
&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;list&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;&lt;span class="c"&gt;// Prints "Bread", NOT "Brown Bread" — list was not changed&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Arrays are value types. Assignment copies everything. If you want shared access, use &amp;amp;list to get a pointer, or switch to slices.&lt;/p&gt;

&lt;p&gt;Mistake 3: Off-by-One on the Last Element&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="n"&gt;groceries&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;3&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"Bread"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Milk"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Eggs"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;groceries&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;3&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;&lt;span class="c"&gt;//  Runtime `panic`: index out of range&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For an array of length 3, the valid indexes are 0, 1, and 2. The last valid index is always len(array) - 1.&lt;/p&gt;

</description>
      <category>go</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Structs in Go</title>
      <dc:creator>Frihk Ian</dc:creator>
      <pubDate>Thu, 04 Jun 2026 07:24:29 +0000</pubDate>
      <link>https://dev.to/frihk_ian/structs-in-go-1jff</link>
      <guid>https://dev.to/frihk_ian/structs-in-go-1jff</guid>
      <description>&lt;p&gt;Let's explore structs in Go. If you know Go's basic types like string, int, and bool, structs let you handle more complex data.&lt;br&gt;
Say you're building a store app. You need a product's name, price, and in-stock status. Using separate variables quickly becomes messy.&lt;br&gt;
Structs can simplify this. Picture structures are like a blueprint. It makes it possible to package all the related information in one neat and organized bundle.&lt;br&gt;
Now let's dive into creating and using custom data types in Go.&lt;/p&gt;
&lt;h2&gt;
  
  
  Declaring Structs
&lt;/h2&gt;

&lt;p&gt;Before using a struct, we first need to describe what it looks like. The result of defining a struct is not a piece of data, but the blueprint of data we want to store later on.&lt;br&gt;
Let's take a look at the declaration of the Product struct:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;package&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="s"&gt;"fmt"&lt;/span&gt;

&lt;span class="c"&gt;// We use the 'type' keyword to define a new custom type.&lt;/span&gt;
&lt;span class="c"&gt;// We name our type 'Product' and specify that it is a 'struct'.&lt;/span&gt;
&lt;span class="k"&gt;type&lt;/span&gt; &lt;span class="n"&gt;Product&lt;/span&gt; &lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="n"&gt;Name&lt;/span&gt;    &lt;span class="kt"&gt;string&lt;/span&gt;  &lt;span class="c"&gt;// Field for the product's name&lt;/span&gt;
   &lt;span class="n"&gt;Price&lt;/span&gt;   &lt;span class="kt"&gt;float64&lt;/span&gt; &lt;span class="c"&gt;// Field for the price&lt;/span&gt;
   &lt;span class="n"&gt;InStock&lt;/span&gt; &lt;span class="kt"&gt;bool&lt;/span&gt;    &lt;span class="c"&gt;// Field to check if it's available&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Creating Struct Instances
&lt;/h2&gt;

&lt;p&gt;Using the struct we just created, let's create a product. Using the struct blueprint to create a piece of data is referred to as creating an instance.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;package&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="s"&gt;"fmt"&lt;/span&gt;

&lt;span class="k"&gt;type&lt;/span&gt; &lt;span class="n"&gt;Product&lt;/span&gt; &lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="n"&gt;Name&lt;/span&gt;    &lt;span class="kt"&gt;string&lt;/span&gt;
   &lt;span class="n"&gt;Price&lt;/span&gt;   &lt;span class="kt"&gt;float64&lt;/span&gt;
   &lt;span class="n"&gt;InStock&lt;/span&gt; &lt;span class="kt"&gt;bool&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="c"&gt;// Creating an instance of Product using a "struct literal."&lt;/span&gt;
   &lt;span class="n"&gt;item1&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;Product&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
       &lt;span class="n"&gt;Name&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;    &lt;span class="s"&gt;"Wireless Mouse"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
       &lt;span class="n"&gt;Price&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;   &lt;span class="m"&gt;25.99&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
       &lt;span class="n"&gt;InStock&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="no"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="p"&gt;}&lt;/span&gt;

   &lt;span class="c"&gt;// Creating an instance but leaving fields blank&lt;/span&gt;
   &lt;span class="n"&gt;item2&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;Product&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
       &lt;span class="n"&gt;Name&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Mousepad"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="p"&gt;}&lt;/span&gt;

   &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;item1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
   &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;item2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Expected Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{Wireless Mouse 25.99 true}
{Mousepad 0 false}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You might be thinking Why does item2 show 0 and false when we didn’t set them?&lt;br&gt;
This is one of Go’s most important behaviours: zero values. In Go, when you declare a variable but don’t give it a value, Go doesn’t leave it empty or undefined (which causes bugs in many other languages). Instead, Go automatically fills it with the zero value for that type.&lt;br&gt;
Since we gave item2 a name, Go automatically sets the price to 0 and in stock to false . This is one of the features in Go that make it exceptional.&lt;br&gt;
Accessing and Modifying Fields&lt;br&gt;
When you want to modify or read information from a struct, you use a dot notation. Consider the dot to be opening up a particular drawer of your filing cabinet to view a folder.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;package&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="s"&gt;"fmt"&lt;/span&gt;

&lt;span class="k"&gt;type&lt;/span&gt; &lt;span class="n"&gt;Product&lt;/span&gt; &lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="n"&gt;Name&lt;/span&gt;    &lt;span class="kt"&gt;string&lt;/span&gt;
   &lt;span class="n"&gt;Price&lt;/span&gt;   &lt;span class="kt"&gt;float64&lt;/span&gt;
   &lt;span class="n"&gt;InStock&lt;/span&gt; &lt;span class="kt"&gt;bool&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="n"&gt;item&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;Product&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
       &lt;span class="n"&gt;Name&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;    &lt;span class="s"&gt;"Keyboard"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
       &lt;span class="n"&gt;Price&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;   &lt;span class="m"&gt;45.00&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
       &lt;span class="n"&gt;InStock&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="no"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="p"&gt;}&lt;/span&gt;

   &lt;span class="c"&gt;// Reading a field&lt;/span&gt;
   &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Original Price:"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Price&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

   &lt;span class="c"&gt;// Modifying a field&lt;/span&gt;
   &lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Price&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="m"&gt;39.99&lt;/span&gt;

   &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Discounted Price:"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Price&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Expected Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Original Price: 45
Discounted Price: 39.99
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Anonymous Structs
&lt;/h2&gt;

&lt;p&gt;Sometimes we want to bundle up some information for one-time use. In such a case, we don’t want to have to go through the trouble of formally defining a whole blueprint. They are particularly useful when holding configuration settings, grouping test inputs, or temporarily organising data for a single function. We use anonymous structs in this way:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;package&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="s"&gt;"fmt"&lt;/span&gt;

&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="c"&gt;// Declaring and initializing a struct at the exact same time&lt;/span&gt;
   &lt;span class="n"&gt;config&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
       &lt;span class="n"&gt;Port&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;
       &lt;span class="n"&gt;Env&lt;/span&gt;  &lt;span class="kt"&gt;string&lt;/span&gt;
   &lt;span class="p"&gt;}{&lt;/span&gt;
       &lt;span class="n"&gt;Port&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"8080"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
       &lt;span class="n"&gt;Env&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;  &lt;span class="s"&gt;"Production"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="p"&gt;}&lt;/span&gt;

   &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Running on port:"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Port&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Expected Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Running on port: 8080
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is a little confusing, if you are new to Go, because you create the blueprint, then use it to create an instance. Let's look at the code snippet again.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;  &lt;span class="n"&gt;config&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;-&lt;/span&gt; &lt;span class="n"&gt;this&lt;/span&gt; &lt;span class="n"&gt;is&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;blueprint&lt;/span&gt; &lt;span class="n"&gt;opening&lt;/span&gt; &lt;span class="n"&gt;brace&lt;/span&gt;
       &lt;span class="n"&gt;Port&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;
       &lt;span class="n"&gt;Env&lt;/span&gt;  &lt;span class="kt"&gt;string&lt;/span&gt;
   &lt;span class="p"&gt;}{&lt;/span&gt;   &lt;span class="o"&gt;&amp;lt;-&lt;/span&gt; &lt;span class="n"&gt;this&lt;/span&gt; &lt;span class="n"&gt;is&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;closing&lt;/span&gt; &lt;span class="n"&gt;brace&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;blueprint&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;followed&lt;/span&gt; &lt;span class="n"&gt;by&lt;/span&gt; &lt;span class="n"&gt;an&lt;/span&gt; &lt;span class="n"&gt;opening&lt;/span&gt; &lt;span class="n"&gt;brace&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;
       &lt;span class="n"&gt;Port&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"8080"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
       &lt;span class="n"&gt;Env&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;  &lt;span class="s"&gt;"Production"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="p"&gt;}&lt;/span&gt;   &lt;span class="o"&gt;&amp;lt;-&lt;/span&gt; &lt;span class="n"&gt;this&lt;/span&gt; &lt;span class="n"&gt;is&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;closing&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Think of this like defining a shape, then filling it. Keep in mind that this is a non-reusable type.&lt;/p&gt;

&lt;h2&gt;
  
  
  Nested (Embedded) Structs
&lt;/h2&gt;

&lt;p&gt;Unlike other programming languages, Go has no “classes” or “inheritance”. Instead, Go employs a technique of packing smaller structs into larger structs, similar to Russian nesting dolls.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;package&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="s"&gt;"fmt"&lt;/span&gt;

&lt;span class="c"&gt;// The smaller struct&lt;/span&gt;
&lt;span class="k"&gt;type&lt;/span&gt; &lt;span class="n"&gt;Address&lt;/span&gt; &lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="n"&gt;City&lt;/span&gt;    &lt;span class="kt"&gt;string&lt;/span&gt;
   &lt;span class="n"&gt;Country&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c"&gt;// The larger struct&lt;/span&gt;
&lt;span class="k"&gt;type&lt;/span&gt; &lt;span class="n"&gt;User&lt;/span&gt; &lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="n"&gt;Name&lt;/span&gt;    &lt;span class="kt"&gt;string&lt;/span&gt;
   &lt;span class="n"&gt;Contact&lt;/span&gt; &lt;span class="n"&gt;Address&lt;/span&gt; &lt;span class="c"&gt;// Embedding the Address struct here&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="n"&gt;player&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;User&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
       &lt;span class="n"&gt;Name&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Alice"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
       &lt;span class="n"&gt;Contact&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Address&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
           &lt;span class="n"&gt;City&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;    &lt;span class="s"&gt;"Nairobi"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
           &lt;span class="n"&gt;Country&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Kenya"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
       &lt;span class="p"&gt;},&lt;/span&gt;
   &lt;span class="p"&gt;}&lt;/span&gt;

   &lt;span class="c"&gt;// Accessing the nested data&lt;/span&gt;
   &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;player&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"lives in"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;player&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Contact&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;City&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Expected Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Alice lives in Nairobi.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Struct Comparison
&lt;/h2&gt;

&lt;p&gt;A question might pop into your brain asking, “Are you able to compare two structs to determine whether they are equal or not?” Yes! Go supports the normal &lt;code&gt;==&lt;/code&gt; operator, but only if all the fields within the struct are comparable.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;package&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="s"&gt;"fmt"&lt;/span&gt;

&lt;span class="k"&gt;type&lt;/span&gt; &lt;span class="n"&gt;Product&lt;/span&gt; &lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="n"&gt;Name&lt;/span&gt;  &lt;span class="kt"&gt;string&lt;/span&gt;
   &lt;span class="n"&gt;Price&lt;/span&gt; &lt;span class="kt"&gt;float64&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="n"&gt;item1&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;Product&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;Name&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Mug"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Price&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;12.50&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
   &lt;span class="n"&gt;item2&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;Product&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;Name&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Mug"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Price&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;12.50&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
   &lt;span class="n"&gt;item3&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;Product&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;Name&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Mug"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Price&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;15.00&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;

   &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Are item1 and item2 identical?"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;item1&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;item2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
   &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Are item1 and item3 identical?"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;item1&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;item3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Expected Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Are item1 and item2 identical? true
Are item1 and item3 identical? false
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Go looks at every single field. If everything matches perfectly, the structs are considered equal.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Photocopy vs. The Original
&lt;/h2&gt;

&lt;p&gt;This is the most essential concept for beginners in Go. Go’s default behavior is to send a struct by value into a function.&lt;br&gt;
If you were to give a friend a copy of your notes, how would they look? If they add a mustache to the photocopied version, you are fine! This is the default behavior of Go. To change an original struct, the function has to be passed a pointer to it (that is, the original notebook).&lt;br&gt;
Let’s observe both of them together:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;package&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="s"&gt;"fmt"&lt;/span&gt;

&lt;span class="k"&gt;type&lt;/span&gt; &lt;span class="n"&gt;Product&lt;/span&gt; &lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="n"&gt;Name&lt;/span&gt;  &lt;span class="kt"&gt;string&lt;/span&gt;
   &lt;span class="n"&gt;Price&lt;/span&gt; &lt;span class="kt"&gt;float64&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c"&gt;// Pass by Value (The Photocopy)&lt;/span&gt;
&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;failedDiscount&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="n"&gt;Product&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Price&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Price&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="m"&gt;5.00&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c"&gt;// Pass by Pointer (The Original)&lt;/span&gt;
&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;successfulDiscount&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;Product&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Price&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Price&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="m"&gt;5.00&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="n"&gt;item&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;Product&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;Name&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"Book"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Price&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;20.00&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;

   &lt;span class="n"&gt;failedDiscount&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c"&gt;// Trying to discount the photocopy&lt;/span&gt;
   &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"After failed discount:"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Price&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

   &lt;span class="n"&gt;successfulDiscount&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c"&gt;// Giving the function the original via '&amp;amp;'&lt;/span&gt;
   &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"After successful discount:"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Price&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Expected Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;After failed discount: 20
After successful discount: 15
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Best Practices &amp;amp; Common Beginner Mistakes
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;In Go, names of fields that begin with a capital letter are “exported” and available to other packages (as opposed to names that start with a lowercase letter, which are “private”). If it begins with a lower-case letter (e.g., name), it belongs only to the package it is in. If in any doubt, make them capitalized so that you can use them freely.&lt;/li&gt;
&lt;li&gt;Pointers for Modification: Keep in mind the photocopy rule. If your function will call to change or update a struct, then you must pass a pointer (*).&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Summary &amp;amp; Your Mini-Challenge
&lt;/h2&gt;

&lt;p&gt;You’ve made it! You’ve learned to structure unsorted variables into orderly, sensible structures. You know how to construct blueprints, make instances, navigate nested data, and update nested data correctly with pointers.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>go</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
