Concurrency in Go vs. Other Languages
SDET.US | Golang
by Brian Warner
3y ago
Concurrency The below video was shared on Twitter. It’s a really great view into concurrency and how Go’s system differs from “Threads” in other languages:   GoRoutines vs. Threads At about 12:44 into the video Eyal gets into the methodology of Go concurrency (Go Routines) and how they differ from threads. The memory stack of a Goroutine is very small. It starts at 2kb. The go stack grows as needed and it also shrinks when no longer needed. If 10,000 goroutines were created, they would only consume 20MB of memory. The above values are much smaller than the stack size of threads. &nb ..read more
Visit website
Dirgo – Directory Brute-Forcer in Golang
SDET.US | Golang
by Brian Warner
3y ago
Back when I was taking the Offensive Security course… we made a lot of use of Kali Linux’s “dirb” utility… it was a brute force utility of a directory structure on a domain.  It would take a dictionary file, and run each word in the dictionary, appended to the domain.  For example: If the domain was mydomain.xxx it would try: mydomain.xxx/a mydomain.xxx/admin and so on. Each time dirb got a 200 OK, it listed it as a valid endpoint. Dirgo Dirgo was a fun project in which I tried to emulate some of this behavior and add a small twist to dirb.  Where dirb looks for a valid res ..read more
Visit website
Golang – Cross Platform Building
SDET.US | Golang
by Brian Warner
3y ago
In my work, I write code on a Mac and deploy to work environments like Windows Server or Centos Linux. So I needed to know how to build cross platform.  Running “go build” just built for my local machine. I came across a video dealing with the subject: In my case, I didn’t follow the entirety of his advice.  I had already installed XCode in the past, so I didn’t need to jump through those hoops. All I needed was to run these params on the build command line, which set the OS and Architecture for the target device: GOOS=linux GOARCH=amd64 go build portScanner.go The above example ..read more
Visit website
Go – GoRoutines, Channels and Threads
SDET.US | Golang
by Brian Warner
3y ago
Each thing I learn in Go, I find myself trying to refer to it as I would in another language (thinking of structs as Classes, for example.) There are however some differences with the Go implementation of these concepts.  In this post I wanted to take some material I’ve been reading about and learning about in various courses and books.  Specifically, I’d like to refer to the concept of concurrency. GoRoutines A goroutine is a way of running functions concurrently.  In Grails there is a concept of using “promises” and tasks… and this is kinda similar.  But keep in mind that ..read more
Visit website
Go and OOP
SDET.US | Golang
by Brian Warner
3y ago
Notes from the course Learn How to Code: Google’s Go Programming Language Go and Types Like all languages values are of certain types.  Types can be int, string, boolean, etc.  Within Go, you can also define your own types. type hacker bool func main(){ var eliot hacker = true fmt.Println(eliot) fmt.Printf("%T ", eliot) } In the above example, eliot is set to a new type called “hacker.”  As we know in Mr. Robot, Eliot is a hacker, so this type has the underlying type of boolean. In the main function, eliot is set to true.  Verifying this and its ..read more
Visit website
Port Scanner written in Go
SDET.US | Golang
by Brian Warner
3y ago
Note: Only utilize a port scanner on sites you have permission to test. Also, note the legalities of port scanners in your territories. Video Demo   Go Project As I’m learning the Go language, I thought I’d work on a small project of making a utility I wrote in Python, in the Go language.  In this case, I chose a port scanner I wrote in Python.  The scanner tries to interrogate ports and return any banner that would indicate what’s installed there. The original code I wrote in Python utilized the socket and sys libraries.  I wrote it while taking an InfoSec course over at ..read more
Visit website
Go Basics – Defer
SDET.US | Golang
by Brian Warner
3y ago
In the Go language there is a concept of deferring an action till later. As far as I can tell, the usefulness of this is to allow for the code to be more readable.   In Todd McLeod’s course on Go, he offers an example of this used in an application he wrote. In the app a file is opened, some actions are done to the opened file (such as writing content to it) and then the file is closed.  Instead of having the close at the bottom of the function, he has the close call under the open call. Example: ipfile, err := os.Open(“ipaddresses.txt”) defer ipfile.Close() In the above example, the ..read more
Visit website
Go – Variadic Functions
SDET.US | Golang
by Brian Warner
3y ago
I hadn’t come across this concept in previous languages I worked in.  In Go, however, this concept came up in an online course I was taking on Udemy.com (from Todd McLeod.)  He raised the concept of a Variadic Function. Variadic Functions These are functions which take an unspecified amount of parameters.  In a regular function you would lock down what parameters are allowed (how many and of what types.)  In a Variadic Function, you use “…” notation to allow for an undefined amount values to get passed. Languages Using Variadic Functions Go is not the only language to use V ..read more
Visit website
Go – Reversing a String
SDET.US | Golang
by Brian Warner
3y ago
As a little example of basic Golang, I wrote a little app that takes user input and reverses the word as output: package main import "fmt" var userInput string func main() { reverseWord() } func reverseWord() { fmt.Println("Input a word> ") fmt.Scan(&userInput) var word_length int = len(userInput) for i := word_length; i > 0; i-- { fmt.Print(userInput[(i - 1):i ..read more
Visit website
Go – Unused Code and the Blank Identifer
SDET.US | Golang
by Brian Warner
3y ago
Unused Code in Go (Golang) In the Go language (Golang) there is a concept that threw me for at first.  In other languages, you can have unused code sitting around.  By unused I don’t mean comments, instead I mean code that isn’t actively being consumed by the application.  For example, if I declared two variables (a and b) but only initialized variable a, even though the variable assignment for b is valid – it will not compile, as variable b is not getting consumed. This language requirement keeps the code useful. Blank Identifiers in Go (Golang) The underscore is the blank iden ..read more
Visit website

Follow SDET.US | Golang on FeedSpot

Continue with Google
Continue with Apple
OR