GoLang: Oracle driver/library renamed to : godror

Posted on Updated on

I’ve posted some previously about using Golang with Oracle. Connecting to an Oracle Database and processing the data.

Golang is very very fast and efficient at processing this data. Much faster than a very commonly used language.

But my previous blog posts on using Golang, have used a driver/library called  goracle.  Here is the link to the blog post on setting it up and connecting to an Oracle Database.

A few months ago goracle was deprecated because of naming (trademark) issues.

But it has been renamed to godror.

The problem now is I need to go an update all the code I’ve written and change all the environment variables to reflect the new driver.

Thankfully the developer of this driver has posted the following code on Github to do this work for you. But you may still encounter some things that require manual changes. If you have only a few Golang programmes, then go ahead and do it manually.

 

You can use "sed" to change everything:

sed -i -e 's,goracle "gopkg.in/goracle.v2",godror "github.com/godror/godror",g; s,gopkg.in/goracle.v2,github.com/godror/godror,g; s/"goracle"/"godror"/g; s/goracle[.]/godror./g' $(find . -type f -name '*.go')
sed -i -e '/goracle.v2/d' go.mod

To change everything using modules:

for dn in $(fgrep -l goracle.v2 $(find . -type f -name 'go.mod') | sed -e 's,/go.mod$,,'); do 
  (cd "$dn" && git pull && sed -i -e 's,goracle "gopkg.in/goracle.v2",godror "github.com/godror/godror",g; s,gopkg.in/goracle.v2,github.com/godror/godror,g; s/"goracle"/"godror"/g; s/goracle[.]/godror./g' $(find . -type f -name '*.go') && sed -i -e '/goracle.v2/d' go.mod  && git commit -am 'goracle -> godror' && git push)
done