Monday, April 01, 2019

Simple GO Codes Functions

Golang  function to fill a specific default value into an Array
Simple code to achieve that

func filldefault(YourArray []int ) {
   for i := range YourArray { YourArray[i] = -1 }
}

Golang function of max and min
Simple code to achieve that

func max(x, y int) {
   if x > y {
        return x
   } else {
       return y
        }
}

func min(x, y int) {
   if x > y {
        return y
   } else {
       return x
       }
}

Golang  function of contain or find an element in an array
Simple code to achieve that

func contain(t []int, x int) bool {
       for _, n := range t {
        if n == x {
          return true
       }
     }
   return false

}

Dockerfile for Httpd on Oracle Linux 7

Please check details on Github OracleLinux Httpd Dockerfile Repo

Dockerfile for Postgresql9.5 on Oracle Linux 7

Please check details on Github OracleLinux Postgresql 9.5 Dockerfile 

Docker: Failed to get D-Bus connection: Operation not permitted

Symptom:

When we build Postgresql 9.5 docker image on  Oracle Linux 7-slim ( FROM oraclelinux:7-slim)
it error out
Docker: Failed to get D-Bus connection: Operation not permitted

Solution:

It is due to Oracle Linux 7-slim is very slim. It takes systemd function out of the image.  D-bus need systemd to function.  In order to fix it ,we need to use a bit heavy linux image which includes systemd.  To use Oracle Linux 7 would fix it (FROM oraclelinux:7)

The full Dockerfile details of Postgresql 9.5 is on github link