<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Gaurang M on Medium]]></title>
        <description><![CDATA[Stories by Gaurang M on Medium]]></description>
        <link>https://medium.com/@gaurang.m?source=rss-16af1b3a2747------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*dmbNkD5D-u45r44go_cf0g.png</url>
            <title>Stories by Gaurang M on Medium</title>
            <link>https://medium.com/@gaurang.m?source=rss-16af1b3a2747------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 08:48:05 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@gaurang.m/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Best Practices for Schema Management and Code Generation in Golang]]></title>
            <link>https://medium.com/@gaurang.m/best-practices-for-schema-management-and-code-generation-in-golang-3ec4601e5d27?source=rss-16af1b3a2747------2</link>
            <guid isPermaLink="false">https://medium.com/p/3ec4601e5d27</guid>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[golang-tutorial]]></category>
            <category><![CDATA[go]]></category>
            <category><![CDATA[golang-development]]></category>
            <dc:creator><![CDATA[Gaurang M]]></dc:creator>
            <pubDate>Wed, 17 Jul 2024 14:26:22 GMT</pubDate>
            <atom:updated>2024-07-17T15:25:36.550Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AjDMWcziD1R3-7ipwmIznQ.png" /></figure><p>Efficient schema management and code generation is crucial for the performance, scalability, and reliability of Go applications, optimizing database interactions becomes essential to ensure seamless operation and maintainability.</p><p>In this blog, we explore best practices for schema management and code generation tailored specifically for Go applications.</p><p>By exploring these practices, you’ll gain insights into structuring database interactions effectively, choosing the right tools for your application’s needs, and maintaining database integrity throughout your Go application’s lifecycle.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/642/1*b1JRZi_Fy4YRwTcWv7ICgw.gif" /></figure><p>This approach emphasizes defining database schema and migrations directly from your Go application code. This method offers several advantages, including version control of schema changes, simplified deployment processes, and ensuring database schema consistency across environments. In this approach, we utilize go migrate for handling database migrations and the sqlc package for automatically generating Go code directly from SQL queries.</p><p><strong>go migrate:</strong> This tool manages database schema changes through defined migration files, ensuring consistency across environments by applying SQL scripts in a controlled manner.</p><p><a href="https://github.com/golang-migrate/migrate">https://github.com/golang-migrate/migrate</a></p><p><strong>sqlc package:</strong> Integrated with Go, sqlc reads SQL queries written alongside Go code, generating type-safe Go structs, interfaces, and methods. This automation enhances code reliability and efficiency in database interactions.</p><p><a href="https://github.com/sqlc-dev/sqlc">https://github.com/golang-migrate/migrate</a></p><p><strong>Step-by-Step Implementation:</strong></p><p><strong><em>Note:</em></strong><em> In this example, PostgreSQL is used</em></p><blockquote><strong>Step 1:</strong> Install go migrate cli</blockquote><pre>scoop install migrate</pre><blockquote><strong>Step 2: </strong>Create empty migration files</blockquote><pre>migrate create -ext sql -dir /path/to/your/migrations init</pre><p>This command will create both the up and down SQL migration files.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/811/1*RyZjrMdj95abNrTglWvxag.png" /></figure><blockquote><strong>Step 3:</strong> Write DDL queries in the migration files</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R0BdQkTe7VgHIQ1ccLk0Vg.png" /></figure><blockquote><strong>Step 4: </strong>Apply migrations to your database</blockquote><p>There are two ways you can apply your migration files to you database:</p><ol><li><strong>Standalone Command</strong></li></ol><p>Use the migrate command to apply the migrations. Specify the database connection string and the path to your migrations directory.</p><pre>migrate -path /path/to/your/migrations -database &quot;postgres://user:password@localhost:5432/database_name?sslmode=disable&quot; up</pre><p>2. <strong>Applying Migrations in Go Code</strong></p><p>Use go migrate in your Go application to apply migrations during startup or as part of your deployment process.</p><p><strong><em>Note:</em></strong><em> You can skip this step, if you are using migrate cli to generate migration files</em></p><pre>import (<br>    &quot;database/sql&quot;<br>    _ &quot;github.com/lib/pq&quot;<br>    &quot;github.com/golang-migrate/migrate/v4&quot;<br>    &quot;github.com/golang-migrate/migrate/v4/database/postgres&quot;<br>    _ &quot;github.com/golang-migrate/migrate/v4/source/file&quot;<br>)<br><br>func main() {<br>    db, err := sql.Open(&quot;postgres&quot;, &quot;postgres://localhost:5432/database?sslmode=enable&quot;)<br>    driver, err := postgres.WithInstance(db, &amp;postgres.Config{})<br>    m, err := migrate.NewWithDatabaseInstance(<br>        &quot;file:///migrations&quot;,<br>        &quot;postgres&quot;, driver)<br>    m.Up()<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*TY_pOvZbuhVnWcnNR0BGZg.gif" /></figure><blockquote><strong>Step 5: </strong>Install sqlc</blockquote><pre>go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest</pre><blockquote><strong>Step 6: </strong>Write DML queries in query.sql</blockquote><p><strong><em>Note:</em></strong><em> Refer the folder structure in step 2</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G3I269sQ9XUdjqNv8GvESg.png" /></figure><blockquote><strong>Step 7: C</strong>onfigure the sqlc.yaml</blockquote><p><strong><em>Note:</em></strong><em> Refer the folder structure in step 2</em></p><p>The sqlc.yaml file is essential for configuring the sqlc tool, which generates type-safe Go code from SQL queries. This file specifies the settings and paths for SQL query and schema files, as well as the output directory for the generated.</p><pre>version: 2<br>sql:<br>- schema: &quot;query.sql&quot;<br>  queries: &quot;query.sql&quot;<br>  engine: &quot;postgresql&quot;<br>  gen:<br>    go:<br>      package: &quot;db&quot;<br>      out: &quot;db&quot;<br>      emit_json_tags: true<br>      emit_pointers_for_null_types: true<br>      query_parameter_limit: 5<br>      overrides:<br>      - column: &quot;authors.id&quot;<br>        go_type: &quot;your/package.SomeType&quot;<br>      rename:<br>        foo: &quot;bar&quot;</pre><p>Please refer to the official document of the sqlc tool for more customization of the generated output.</p><blockquote><strong>Step 8: </strong>Use the sqlc command to generate the code from migration folder</blockquote><pre>cd /path/to/your/sqlc<br>sqlc generate</pre><p>This command will read the configuration from sqlc.yaml, parse the SQL files in the specified directories, and generate Go code in the /db/generated directory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/724/1*UlR-geaFvKRrjUBeKvemkQ.png" /></figure><p>The generated code includes:</p><p><strong>Models</strong>: Structs for your database tables.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5Q6b94nmPI18eLZeIVfzYQ.png" /></figure><p><strong>Querier Interface</strong>: An interface that defines methods for your queries</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9to-61vv_3R0eg8k08D1Sg.png" /></figure><p><strong>Query Methods</strong>: Functions that execute the queries and return results as Go structs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Cjm9xPjJX-gqmLupat-K0w.png" /></figure><h3>Conclusion</h3><p>By adhering to best practices and leveraging tools like go migrate and sqlc, you can ensure that your database interactions are both reliable and maintainable. These tools streamline the process of schema migrations and code generation, helping you maintain consistency across different environments and reducing the risk of errors.</p><p>Implementing these practices directly from your Go application code brings numerous benefits. It allows for version control of schema changes, simplifies deployment processes, and ensures database schema consistency. Through the use of go migrate, you can manage schema changes with precision, and with sqlc, you can generate type-safe Go code from your SQL queries, enhancing the reliability and efficiency of your codebase.</p><p>By following the step-by-step implementation guide provided, you can set up and utilize these tools effectively in your Go applications. This approach not only improves the development workflow but also contributes to the scalability and reliability of your applications. Embrace these best practices to ensure that your database management is optimized, leading to seamless operation and long-term maintainability of your Go projects.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3ec4601e5d27" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CORS Setup in Your Golang Application]]></title>
            <link>https://medium.com/@gaurang.m/allowing-cross-site-requests-in-your-gin-app-golang-1332543d91ed?source=rss-16af1b3a2747------2</link>
            <guid isPermaLink="false">https://medium.com/p/1332543d91ed</guid>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[go]]></category>
            <category><![CDATA[golang-development]]></category>
            <category><![CDATA[golang-tutorial]]></category>
            <dc:creator><![CDATA[Gaurang M]]></dc:creator>
            <pubDate>Wed, 26 Jun 2024 13:04:40 GMT</pubDate>
            <atom:updated>2024-07-21T07:35:44.075Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s9q1OVlzfv7kSfj5aHvhZQ.png" /></figure><p>In the modern web, applications often need to request resources from different domains. This can range from fetching data from an API to loading resources like fonts or scripts. However, browsers implement a security feature known as the Same-Origin Policy to restrict such requests, protecting users from potential security risks. Enter <strong>CORS (Cross-Origin Resource Sharing)</strong>, a vital mechanism that allows servers to control and authorize cross-origin requests in a secure manner. Before jumping into the setup, let’s know more about CORS.</p><h4><strong>What is CORS?</strong></h4><p>CORS stands for Cross-Origin Resource Sharing. It is a protocol that uses HTTP headers to allow a server to specify any other origins (domains) that a web browser should permit the loading of its resources. This mechanism provides web applications the flexibility to bypass the Same-Origin Policy in a secure and controlled way.</p><h4>Why is CORS Important?</h4><p>The primary purpose of CORS is to protect users from potential security vulnerabilities that could arise from cross-origin requests. Without CORS, a malicious website could make unauthorized requests to another website on behalf of a user, leading to data breaches or other security issues. CORS ensures that web applications can only request resources from allowed origins, thereby providing an additional layer of security.</p><h4>How Does CORS Work?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/754/1*oAvWd-LjmCXBneapQrrKFQ.png" /></figure><p><strong>Step 1: </strong>By default, browsers enforce the “<strong>same-origin policy</strong>” which restricts web pages from making requests to resources from different domains. This is a security measure to prevent malicious scripts from stealing your data.</p><p><strong>Step 2:</strong> If a script on domain A tries to access a resource from domain B using methods that modify data (PUT, POST, DELETE), the browser sends a <strong>“preflight request” </strong>first. This preflight request uses the OPTIONS method to ask domain B if the actual request from domain A is allowed.</p><p><strong>Step 3: </strong>The server on domain B responds to the preflight request with CORS headers. These headers specify whether the request from domain A is allowed, and if so, what kind of requests (methods) are allowed, what headers are allowed, etc.</p><pre>Access-Control-Allow-Origin: Specifies which origins are allowed to access the resource.<br>Access-Control-Allow-Methods: Lists the HTTP methods allowed when accessing the resource.<br>Access-Control-Allow-Headers: Specifies the headers allowed in the actual request.<br>Access-Control-Allow-Credentials: Indicates whether the response to the request can be exposed when credentials are included.<br>Access-Control-Max-Age: Defines the maximum time the results of a preflight request can be cached.</pre><p><strong>Step 4: </strong>If the preflight request is successful, the browser proceeds with the <strong>actual request</strong> (GET, PUT, POST, DELETE) based on the allowed methods and headers from the CORS response.</p><p>If you want to learn more about CORS, please refer to the MDN Docs article on CORS.(<a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS">https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS</a>)</p><h4><strong>Problem with CORS Setup in Gin</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*bVIj2w8Xr70h6UcZyvM7eg.jpeg" /></figure><p>There are several packages available for setting up CORS in Gin, two of which are commonly referenced:</p><p><a href="https://github.com/gin-contrib/cors">https://github.com/gin-contrib/cors</a></p><p><a href="https://github.com/itsjamie/gin-cors">https://github.com/itsjamie/gin-cors</a></p><p>It’s crucial to mention that while these packages provide a convenient way to import CORS middleware into your Gin application, users often encounter challenges with their setup due to inadequate documentation. Simply importing the middleware does not guarantee that it will work seamlessly without additional configuration.</p><h4>Configuring CORS in Gin</h4><pre>package main<br><br>import (<br> &quot;&lt;path_to_handlers&gt;/handlers&quot;<br> &quot;github.com/gin-gonic/gin&quot;<br> &quot;strings&quot;<br>)<br><br>func main() {<br> // Initialize a new Gin router with default middleware: logger and recovery middleware<br> r := gin.Default()<br><br> // Use the CORS middleware defined below<br> r.Use(corsMiddleware())<br><br> // Define route handlers<br> r.GET(&quot;/ping&quot;, handlers.Ping)<br> r.GET(&quot;/pong&quot;, handlers.Pong)<br><br> // Run the server on port 8082<br> err := r.Run(&quot;:&quot; + &quot;8082&quot;)<br> if err != nil {<br>  panic(err)<br> }<br>}<br><br>// CORS middleware function definition<br>func corsMiddleware() gin.HandlerFunc {<br> // Define allowed origins as a comma-separated string<br> originsString := &quot;https://example.com,https://test.com&quot;<br> var allowedOrigins []string<br> if originsString != &quot;&quot; {<br>  // Split the originsString into individual origins and store them in allowedOrigins slice<br>  allowedOrigins = strings.Split(originsString, &quot;,&quot;)<br> }<br><br> // Return the actual middleware handler function<br> return func(c *gin.Context) {<br>  // Function to check if a given origin is allowed<br>  isOriginAllowed := func(origin string, allowedOrigins []string) bool {<br>   for _, allowedOrigin := range allowedOrigins {<br>    if origin == allowedOrigin {<br>     return true<br>    }<br>   }<br>   return false<br>  }<br><br>  // Get the Origin header from the request<br>  origin := c.Request.Header.Get(&quot;Origin&quot;)<br><br>  // Check if the origin is allowed<br>  if isOriginAllowed(origin, allowedOrigins) {<br>   // If the origin is allowed, set CORS headers in the response<br>   c.Writer.Header().Set(&quot;Access-Control-Allow-Origin&quot;, origin)<br>   c.Writer.Header().Set(&quot;Access-Control-Allow-Credentials&quot;, &quot;true&quot;)<br>   c.Writer.Header().Set(&quot;Access-Control-Allow-Headers&quot;, &quot;Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization, accept, origin, Cache-Control, X-Requested-With&quot;)<br>   c.Writer.Header().Set(&quot;Access-Control-Allow-Methods&quot;, &quot;POST, OPTIONS, GET, PUT&quot;)<br>  }<br><br>  // Handle preflight OPTIONS requests by aborting with status 204<br>  if c.Request.Method == &quot;OPTIONS&quot; {<br>   c.AbortWithStatus(204)<br>   return<br>  }<br><br>  // Call the next handler<br>  c.Next()<br> }<br>}</pre><p><strong>Gin Setup</strong>: We start by initializing a Gin router (r := gin.Default()) and adding CORS middleware (r.Use(corsMiddleware())).</p><p><strong>CORS Middleware</strong>: The corsMiddleware function defines which origins are allowed (originsString := &quot;https://example.com,https://test.com&quot;). It checks incoming requests against this list and sets appropriate CORS headers (Access-Control-Allow-Origin, Access-Control-Allow-Methods, etc.) if the request origin is allowed.</p><p><strong>Handling Requests</strong>: Each incoming request passes through the middleware. If it’s a preflight OPTIONS request (used by browsers to check permissions), the middleware responds with status 204 and aborts further processing. Otherwise, it allows the request to proceed to the appropriate handler (handlers.Ping and handlers.Pong in this case).</p><h4>Conclusion</h4><p>In conclusion, implementing CORS (Cross-Origin Resource Sharing) in your Gin application is crucial for securely enabling cross-origin requests while adhering to browser security policies. By utilizing middleware and configuring appropriate CORS headers, such as Access-Control-Allow-Origin and Access-Control-Allow-Methods, you can ensure that your application only permits requests from trusted origins. This not only enhances security by preventing unauthorized access but also enables seamless integration with external resources, thereby improving the flexibility and functionality of your web application.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1332543d91ed" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Golang project structure]]></title>
            <link>https://medium.com/@gaurang.m/golang-project-structure-13b953fb6117?source=rss-16af1b3a2747------2</link>
            <guid isPermaLink="false">https://medium.com/p/13b953fb6117</guid>
            <category><![CDATA[golang-development]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[golang-tutorial]]></category>
            <category><![CDATA[go]]></category>
            <dc:creator><![CDATA[Gaurang M]]></dc:creator>
            <pubDate>Sun, 16 Jun 2024 15:53:36 GMT</pubDate>
            <atom:updated>2024-06-16T15:53:36.439Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xgs5QH3E1_wxkgEzi-5FDQ.jpeg" /></figure><p>One of the aspects that makes Go (or Golang) attractive is its flexibility, in organizing code. Unlike languages and frameworks such as Java with its package structure or Ruby on Rails with its emphasis on convention over configuration Go allows you the freedom to structure things as you see fit. This adaptability is a factor in the appeal of Go — whether you’re working on a tool or a large intricate application you have the freedom to arrange your project in a manner that best suits your needs. Go emphasizes the use of modules and packages making it easy for your code to be shared and reused without having to worry about its location, in your directory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*bHGc9yBoOwSEBaLeSoA_EQ.jpeg" /></figure><p>You’ll find plenty of articles and resources out there that suggest how you should structure your Go projects, but it’s important to remember that these are often project-specific and not one-size-fits-all solutions. In fact, they can sometimes add to the confusion with too much clutter and conflicting advice. For instance, check out these repositories and guidelines:</p><ul><li><a href="https://github.com/golang-standards/project-layout">https://github.com/golang-standards/project-layout</a></li><li><a href="https://github.com/benbjohnson/wtf">https://github.com/benbjohnson/wtf</a></li></ul><p>While these articles provide detailed breakdowns of Go project structures, they might be more than you need if you’re just starting out or working on a simpler project. The key is to find a structure that works best for your specific needs and to evolve it as your project grows.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fgM3ASfNYr-quPgsblsHhg.jpeg" /></figure><p>When structuring Go projects, two common approaches are:</p><ul><li><strong>Multi Modular Structure</strong>: Suited for larger applications, it organizes code into distinct directories for commands, internal packages, and external libraries, promoting better modularity and scalability.</li><li><strong>Single Standalone Structure</strong>: Ideal for smaller projects or utilities, everything resides in the main directory, keeping things straightforward and easy to manage.</li></ul><h4><strong>Multi Modular Structure</strong></h4><p>The “Multi Modular Structure” is a project organization strategy tailored for larger applications, aiming to enhance modularity and scalability. Here’s a breakdown of your project structure:</p><pre>go-project/<br>├── .github/<br>│   └── workflows/<br>│       └── deploy.yml<br>├── cmd/<br>│   ├── app-1/<br>│   │   └── main.go<br>│   └── app-2/<br>│       └── main.go<br>├── docker/<br>│   ├── app-1.Dockerfile<br>│   └── app-2.Dockerfile<br>├── app-1/<br>│   ├── db/<br>│   │   ├── db.go<br>│   │   ├── models.go<br>│   │   ├── querier.go<br>│   │   ├── query.sql.go<br>│   │   ├── migrations/<br>│   │   │   ├── 000001_init_schema.down.sql<br>│   │   │   ├── 000001_init_schema.up.sql<br>│   │   │   └── query.sql<br>│   │   └── sqlc.yaml<br>│   ├── app-1-handler.go<br>│   ├── app-1-type.go<br>│   └── app-1.go<br>├── app-2/<br>│   ├── db/<br>│   │   ├── db.go<br>│   │   ├── models.go<br>│   │   ├── querier.go<br>│   │   ├── query.sql.go<br>│   │   ├── migrations/<br>│   │   │   ├── 000001_init_schema.down.sql<br>│   │   │   ├── 000001_init_schema.up.sql<br>│   │   │   └── query.sql<br>│   │   └── sqlc.yaml<br>│   ├── app-2-handler.go<br>│   ├── app-2-type.go<br>│   └── app-2.go<br>├── utils/<br>│   └── graphql.go<br>├── .gitignore<br>├── docker-compose.yml<br>├── go.mod<br>└── README.md</pre><p>This directory structure divides a Go project into logical components like commands, Docker configurations, application logic, and utilities. It helps large applications by keeping code organized and manageable. With clear separation of concerns, teams can work on different parts independently, making it easier to scale and maintain the project over time.</p><h4><strong>Single Standalone Structure</strong></h4><p>The Single Standalone Structure is a simple and straightforward organization method suitable for smaller projects or utilities in Go. In this structure, all files and directories reside directly within the main directory, without any subdirectories for different components like commands, utilities, or configurations. This approach is often used when the project is small enough that the additional complexity of a more elaborate structure is unnecessary.</p><pre>app-1<br>├── api/<br>│   ├── helper/<br>│   │   └── helper.go<br>│   ├── middleware/<br>│   │   └── middleware.go<br>│   ├── models/<br>│   │   └── models.go<br>│   └── server/<br>│       ├── router.go<br>│       └── server.go<br>├── assets/<br>├── constants/<br>│   ├── constants.go<br>│   └── errors.go<br>├── database/<br>│   └── database.go<br>├── firebase/<br>│   └── firebase.go<br>├── logger/<br>│   └── logger.go<br>├── util/<br>│   └── util.go<br>├── .gitignore<br>├── docker-compose.yaml<br>├── Dockerfile<br>├── go.mod<br>├── go.sum<br>├── main.go<br>└── README.md</pre><p>This directory structure represents a standalone application, neatly organizing its components. The directory centralizes API-related functionalities like helpers, middleware, models, and server logic. Other directories handle assets, constants, database interactions, Firebase services, logging, and utilities. It simplifies navigation, improves code readability, and streamlines collaboration among developers.</p><h4>Conclusion</h4><p>Golang’s flexibility in organizing project structure is a key aspect of its appeal. Unlike more rigid frameworks, Go allows developers to arrange their code in a manner that best suits their needs, whether they are working on small utilities or large applications.</p><p>The two common approaches to structuring Go projects — Multi Modular Structure and Single Standalone Structure — cater to different project sizes. The Multi Modular Structure is suited for larger applications, enhancing modularity and scalability. Conversely, the Single Standalone Structure is ideal for smaller projects, keeping everything simple and easy to manage.</p><p>Ultimately, there is no one-size-fits-all solution for structuring Go projects. The best approach is to find a structure that works for your specific needs and to adapt it as your project evolves. By leveraging Go’s flexibility, you can create a maintainable and efficient codebase tailored to your project’s requirements.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=13b953fb6117" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>