ngrok-go package, to create a tunnel!
Learner, Love to make things simple, Full Stack Developer, StackOverflower, Passionate about using machine learning, deep learning and AI
Search for a command to run...
Learner, Love to make things simple, Full Stack Developer, StackOverflower, Passionate about using machine learning, deep learning and AI
No comments yet. Be the first to comment.
Move beyond traditional RESTful thinking. Learn how to design APIs specifically for MCP (Model Context Protocol) servers. This guide covers the shift in mindset, a practical OpenAPI 3.1 example, and a Spring Boot implementation to make your services ...

Extending Kestra to Every Corner of Your Data Stack. Introduction: The Power of Plugins Imagine you're a master chef. You don't just have one knife - you have specialized tools for every task: a paring knife for delicate work, a chef's knife for chop...
Mastering Complex Orchestration Scenarios. Introduction: The Orchestrator's Toolkit Imagine you're conducting a symphony. You don't just wave your baton - you cue sections, adjust tempo, handle surprises, and ensure harmony. That's what advanced work...
From Data Extraction to Loading - A Practical Guide Introduction: Why ETL Still Matters in the Modern Data Stack Remember when data engineering was "extract, transform, load"? Some say ETL is dead, replaced by ELT, reverse ETL, and data mesh. But her...
Building Blocks of Declarative Orchestration. Introduction: The Power of Simplicity Imagine trying to build a house without understanding bricks, beams, and blueprints. That's what using an orchestration tool without understanding its core concepts f...

When developing a web application, you might find yourself needing to test it on a public URL or give access to it to someone outside of your local network. However, this can be a challenge as you might not have a public URL or a domain name. This is where ngrok comes in handy.
ngrok is a tool that allows you to create a secure public URL (a tunnel) to your local machine, thus allowing you to test and share your web application with others. The ngrok-go package is a Go package that allows you to programmatically create and manage ngrok tunnels from within your Go application.
In this article, we will explore the ngrok-go package and how it can be used to create ngrok tunnels programmatically.
Before we dive into the ngrok-go package, there are a few prerequisites that you should have:
A Go development environment set up
A basic understanding of HTTP and networking
The ngrok-go package can be installed using the following command:
go get github.com/inconshreveable/ngrok/...
Once the ngrok-go package is installed, you can start using it to create ngrok tunnels programmatically. Here's an example:
package main
import (
"fmt"
"net/http"
"github.com/inconshreveable/ngrok"
)
func main() {
// Create a new ngrok tunnel
ngrokURL, err := ngrok.Connect(8080)
if err != nil {
panic(err)
}
fmt.Printf("ngrok tunnel URL: %s\n", ngrokURL)
// Start a HTTP server to serve some content
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "Hello, world!")
})
http.ListenAndServe(":8080", nil)
}
In this example, we first create a new ngrok tunnel by calling the ngrok.Connect function and passing in the port number that we want to expose (in this case, port 8080). The ngrok.Connect function returns the public URL of the ngrok tunnel that was created.
We then start a HTTP server on port 8080 and serve some content. This server will be accessible through the ngrok tunnel that we created earlier.
When we run this program, we should see output similar to the following:
ngrok tunnel URL: http://b873d185.ngrok.io
This URL can be shared with others to allow them to access our HTTP server.
A ngrok-go package is a powerful tool that allows you to create ngrok tunnels programmatically from within your Go applications. This can be incredibly useful when testing or sharing your web applications with others. With just a few lines of code, you can create a secure public URL to your local machine, and easily share your work with the world.
I hope this helps, you!!
More such articles:
https://www.youtube.com/channel/UCiTaHm1AYqMS4F4L9zyO7qA
\==========================**=========================
If this article adds any value to you then please clap and comment.
Let’s connect on Stackoverflow, LinkedIn, & Twitter.