How Do You Troubleshoot the Go Programming Error ‘non-name m1[“foo”] on left side of :=’?

Problem scenario
You are running a Go program. You see this message about "command-line-arguments":

non-name m1["foo"] on left side of :=

What should you do?

Possible Solution
Can you try to use "=" instead of ":="? This may fix your problem.

The := is a variable declaration and an assignment. If your map has been declared, individual values in it should be assigned with an "=" (equals sign).

How Do You Use a Function in Golang?

Problem scenario
You are trying to learn to program in Go. How do you use a function?

Solution
Prerequisite
This assumes that you have installed Golang; if you need assistance with this, see this posting.

Procedures
1. Create a file called b.go with this as the content:

package main

import "fmt"

// ContintFunction will display a message
func ContintFunction() {
        fmt.Println("Hello from Continual Integration")
}

func main() {
        ContintFunction()
}

2. Run it like this: go run b.go

How Do You Find out What Packages You Can Install That Are Related to a Certain Category when Using Ubuntu Linux?

Problem scenario
You want to find what Java packages are available on the configured repositories of the Linux server you are using. What do you do?

Solution
Run a command like this: apt-cache search java

You can replace "java" with a word of the package you want to install.

If you want to learn more about the package and have its exact name, run this command: apt-cache showpkg java-common

How Do You Find out What Packages You Can Install That Are Related to a Certain Category when Using Linux SUSE?

Problem scenario
You want to find what Java packages are available on the configured repositories of the Linux SUSE server you are using. What do you do?

Solution
Run this command: zypper se java

You can replace "java" with a word of the package you want to install.

In Python, How Do You Call a Bound Function as a New Thread with the thread Module?

Problem scenario
You want to write a program to call a bound function in a new thread. How do you do this?

Solution
Run this program (e.g., python foobar.py):

import _thread as thread
 class mighty:
   def cool():
     print("Cool.")
def contint():
   print("Hello!")   
if name == "main":
     foobar = thread.start_new_thread(mighty.cool, () )
     print("thread finished…exiting")

How Do You Generate a 100 GB Log File?

Problem scenario
You want to generate a large log file to use later on (e.g., for the Elastic Stack or Splunk). How do you create a 100 GB log file?

Solution
Find an example log to base the generation off. Run these commands to find a log that you would want to copy its format:

cd /var/log
ls -lh --sort=size
sudo tail foobar # where foobar is the name of the log file you want to sample

2. Draft a script like this, but substitute "foobar" with the name of the file you want to change.

for i in {1..1000}
  do cat /var/log/foobar >> /tmp/newfile.log
done

# The new file will be 1,000 times as large as the original log file.  
# You will want to change 1000 to a different value so the resulting file is 100 GB.

3. Name the script "cool.sh" and run it: bash cool.sh

How Do You Create a List of Strings in Golang?

Problem scenario
Lists have a fixed length number of discrete items. You want the items in the list to be strings. How do you create a list of strings in Golang?

Solution
1. Use this program called animal.go:

package main

import "fmt"

func main() {
  var x [10]string
  x[0] = "dog"
  x[1] = "cat"
  x[2] = "hamster"
  x[3] = "rabbit"
  x[4] = "chicken"

  for i := 0; i < 5; i++ {
    fmt.Println(x[i])
  }
}

2. Run it like this: go run animal.go

How Do You Get SonarQube to Use a New Database Connection and Change It from the Previous One It Was Working with?

Problem scenario
You try to start an old SonarQube instance but with a new database connection. In the web.log file you see a message like this: "Can not connect to database. Please check connectivity and settings." What should you do?

Solution
Go to sonar.properties. Find the connection string for the new database. It should look something like this:

sonar.jdbc.url=jdbc:oracle://FQDN:1521:XE

The default port for Oracle databases is 1521. Are the last three characters "/XE"? Change the "/" to ":". XE stands for Express Edition. Some sources indicate that the format should be hostname:portnumber:sid

The "sid" (or service name) for Oracle is often "XE" (which stands for Express Edition). The character separating the TCP port number and the sid should be a colon ":"

Details and reference information can be found in these links:
https://docs.oracle.com/cd/E11882_01/appdev.112/e13995/oracle/jdbc/OracleDriver.html
https://docs.oracle.com/cd/B25329_01/doc/appdev.102/b25320/getconn.htm

How Do You Delete Browser Data from Chrome when Your First Attempt Failed?

Problem scenario
In Chrome you deleted browsing data including cookies and autofill form data. You closed the browser and reopen it, but old URLs still show up. What should you do?

Solution
Go to History -> Clear browsing data -> and go to "Time Range" (the drop down menu). Choose "All time" and then go to "Clear data".