How to set IST time in Remote Machine? - go

loc, err := time.LoadLocation("Asia/Calcutta")
if err != nil{
fmt.Println(err)
}
now := time.Now().In(loc)
fmt.Println(now)
First I wanted IST time format in my remote machine,
But I got the following error, In local machine working fine.
The error comes only for Remote Machine*
I got an error:
The system cannot find the path specified.
panic: time: missing Location in a call to Time. In

//IST -> UTC + 5:30
fixedZone := time.FixedZone("IST", 5*3600+1800)
in := time.Now().In(fixedZone)
log.Println(in)
log.Println(in.Zone())
log.Println("--------------------------")
// my time is UTC+8:00
name, offset := time.Now().Zone()
log.Println(name)
log.Println(offset)
2022/08/24 17:53:35 2022-08-24 15:23:35.0625673 +0530 IST
2022/08/24 17:53:35 IST 19800
2022/08/24 17:53:35 --------------------------
2022/08/24 17:53:35 CST
2022/08/24 17:53:35 28800

This generally may happen when the function time.LoadLocation() is called and it looks for a reference for the time zoneinfo and the same is not available on the Remote machine. You should check as to where you are running this program; the Remote machine also contains a valid path for the zoneinfo.zip file .
If you were using this earlier and have recently upgraded to a new version for Go,also update the zoneinfo.zip file to the latest version from the golang repository on the same remote machine as well.
I would also recommend you to check details on Go Package for func LoadLocation.

Related

go Packed binary and lost permission to run on server

Steps:
go build . /main.go
./main # run
curl localhost:8080 # app run on 8080
The app exits with non-removable permissions attached
step image
I'm developing a go app for the first time if there is anything else I need to provide I will update the content as soon as possible, thanks
Because curl's is an unmatched route, we won't post the contoller code here
package main
import (
"github.com/gin-gonic/gin"
"example.app/common"
"example.app/config"
"example.app/controller"
"example.app/db"
"example.app/middleware"
)
func main() {
config.Initialize()
gin.SetMode(config.AppMode)
r := gin.Default()
r.SetTrustedProxies([]string{"::"})
// setup auth middleware.
r.Use(middleware.Auth())
common.InitValidator()
// setup routes.
controller.Initialize(r)
r.Run(":" + config.AppPort)
}
go mode code
env
Linux instance-220907111205 4.15.0-22-generic #24-Ubuntu SMP Wed May 16 12:15:17 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

Golang MSI can't see mounted drives on windows

So I have an windows msi installer that I created by cross compiling from a golang program and installed on a client windows machine. The program sends data out from a folder on the windows machine to a Kinesis stream. The program works fine for all files and folders on the local C:\ drive.
My issue is that when the client is using a mounted NTFS drive ("I://, J://, D://") I get an error message with
level=info msg="Ignoring target I:\\xml with invalid stat: open I:\\xml: The system cannot find the path specified."
No matter the mounted drive (E,F,G, etc) I get the same error message.
I've tried this across multiple clients and received the same error.
So just for background- I'm compiling the program using wine to get it to an msi when building. The program is taking on a SYSTEM USER role and I've already checked permissions on the mounted directories (and made them wide open- still no luck). Been banging my head against the wall over this one for a while so the question is: has anyone else had an issue like this?
Don't know how much this will help but here is the specific portion of GO code I'm using:
p, err := filepath.Abs(t.Path)
if err != nil {
Logger.Infof("Ignoring invalid target path: %s, error: %s", t.Path, err)
continue
}
_, err = os.Lstat(t.Path)
if err != nil {
Logger.Infof("Ignoring target %s with invalid stat: %s", t.Path, err)
continue
}
c.targets = append(c.targets, site.WatchTarget{p, t.SrcTag})
I've tried os.Stat, Lstat and even os.Open to no avail. Just about at the end of my tether on this one.
The ideal result would be a suggestion on any changes you could suggest that would allow a system user from a cross compiled go program to see mounted network drives.

How can I get samples when running go with pkg/profile enabled?

I have the following in my main block:
func main() {
defer profile.Start().Stop()
fmt.Println("running version", version, "built on", date)
fmt.Println()
cmd.Execute()
time.Sleep(2 * time.Second)
}
where cmd is a cobra subcommand. I do a go build, and then I run the binary. I can see that it generates a pprof file:
2018/09/13 18:43:26 profile: cpu profiling enabled, /tmp/profile705487093/cpu.pprof
... output deleted ...
2018/09/13 18:43:31 profile: cpu profiling disabled, /tmp/profile705487093/cpu.pprof
Then I'm trying to analyze it, using:
go tool pprof /root/code/debug/evented /tmp/profile705487093/cpu.pprof
But when pprof opens, I see this:
File: evented
Type: cpu
Time: Sep 13, 2018 at 6:43pm (UTC)
Duration: 5.49s, Total samples = 0
In case it helps, I'm running go version go1.11 linux/amd64 on a Ubuntu 16.04.5 LTS. Not sure whether it matters, but I'm trying to inspect the pprof output on a DigitalOcean droplet.
Is there something that I'm doing wrong? Thanks!
After looking a bit through the comments of the profile pkg, I managed to get some samples, by doing this:
runtime.SetCPUProfileRate(5000)
before calling the defer profile.Start().Stop() line.

ORA-609 TNS-12638 Credential retrieval failed

I'm having this error every second
alert.log
08/03/2018 11:32:07 a.m. - opiodr aborting process unknown ospid (3888) as a result of ORA-609
08/03/2018 11:32:17 a.m. - opiodr aborting process unknown ospid (18896) as a result of ORA-609
sqlnet.log
Fatal NI connect error 12638, connecting to:
(LOCAL=NO)
VERSION INFORMATION:
TNS for 64-bit Windows: Version 11.2.0.4.0 - Production
Oracle Bequeath NT Protocol Adapter for 64-bit Windows: Version 11.2.0.4.0 - Production
Windows NT TCP/IP NT Protocol Adapter for 64-bit Windows: Version 11.2.0.4.0 - Production
Time: 08-MAR-2018 11:33:49
Tracing not turned on.
Tns error struct:
ns main err code: 12638
TNS-12638: Credential retrieval failed
ns secondary err code: 0
nt main err code: 0
nt secondary err code: 0
nt OS err code: 0

exec not running command from Golang application

I am running a Go application in a Debian environment. All my development has been carried out on OSX and it ran fine, but I am having a problem running a command on shell from my Go code.
cmdName := "cwebp"
cmdArgs := []string{srcPath, "-o", dstPath}
log.Printf("Executing %s : %+v", cmdName, cmdArgs)
cmd := exec.Command(cmdName, cmdArgs...)
_, err := cmd.StdoutPipe()
if err != nil {
log.Printf("Error: %s", err)
}
err = cmd.Run()
if err != nil {
log.Printf("Error: %s", err)
}
The application process is running from my root user and the command works fine when I run it from shell.
Earlier, I thought that I am facing the issue due to an incorrect PATH environment variable. On printing that before running the command, I get the correct path. Moreover, I have tried to use LookPath and got the correct path as /usr/local/bin/cwebp.
The problem was not with the execution of the command but somehow Go was not able to find the correct library. On checking the output of the command, I got the following:
cwebp: error while loading shared libraries: libwebp.so.5: cannot open shared object file: No such file or directory
This led me to the direction that the installation of libwebp must have been faulty. Earlier, I had built libwebp from source. So, I installed it via apt-get install libwebp-dev and the command ran successfully.

Resources