This is the first time I have heard of this function, this is the same as python's args for unknown number of positional arguments in a function.
I am using fmt.Scanln() to read user's input, the reader stops at newline, on previous case I use fmt.Scanf() but it reads the first input and terminates. This is part of an exercise for my golang tutorial.
Reference: https://github.com/golang/go/wiki/Iota iota is used to declare incremental constants, each constant block will start iota with 0, then each constant within the block will increment the iota. Iota resets back to 0 if it is declared on another constant block.
Another exercise on golang, experience in python helps me pick up golang rather quickly. calculate the area of a circle.
This is an exercise of my golang course. The purpose is to convert Fahrenheit to Celcius
I have been doing a few HTB machines and used some tools for enumeration and a lot of those tools are made from Golang, I wished to create my own tool in Go and hence I am starting to learn about the language. Here is a code snippet on how to interact with OS commands. … Continue reading [Go]Execute commands in Linux
This extends the previous post about capturing user's input. The captured input is stored into a file known as text.txt. To write a string to a file ioutil.WriteFile is used, this method requires three arguments: filename in string string byte slice, which is the ascii representation of the string slice The permission, if unsure check … Continue reading [Go]Capture user’s entered sentence and save into a file.
There are several ways to get the input string. The first method is to use bufioNewReader(os.Stdin) to read the stdin, using the reader object get the user input from stdin until a delimiter is input by user, the entire string includes the delimiter enter by user. First method, use bufio to get stdin Second method … Continue reading [Go]Get user’s input string
Open the file and read its contents, if the file does not exist exit the program with exit status 1, log.Fatal() not only logs the problem but also do os.Exit(1)
You cannot change the value of a struct directly to an array, you will need to dereference the pointer and change the value. There are two methods one is to reference the object's index and change the struct value the other is to pass in the memory address of the current object index and use … Continue reading [Go]Change value to a struct in an array