go's questions - English 1answer

29.724 go questions.

I have fsnotify watching some dir for me. When I set log.SetOutPut(os.Stdout), everything is fine. It will print 3 lines if I modify one file.But after I change it to log.SetOutPut(somefile), it logs ...

I'm using golang with OpenGL. I use TEXTURE_2D_ARRAY load texture render a cube, but it result is a black cube. I'm sure the texture unit is specified correctly because when I use ActiveTexture(gl....

I have two collections. I am using MongoDB version 3.4. Collection 1 called Results Collection 2 called Code_Value Here i have to update automatically the code in the result using the ...

My application is running in Kubernetes pods and I would like to use golang/groupcache to distribute key/value entities amongst instances of the app. The groupcache library in each of my app ...

So I'm basically trying to find out the best way to get to something like this: package main import "fmt" type SomeStruct struct { } type SomeInterface interface { ...

I'll just post my code: /* * Role will ALWAYS reserve the session key "role". */ package goserver const ( ROLE_KEY string = "role" ) type Role string //if index is higher or equal than role, ...

I have an interface{} variable and I know it's a pointer to slice: func isPointerToSlice(val interface{}) bool { value := reflect.ValueOf(val) return value.Kind() == reflect.Ptr && ...

Following is an excerpt from source code of http/request.go line 290: // WithContext returns a shallow copy of r with its context changed // to ctx. The provided ctx must be non-nil. func (r *Request)...

In Golang, I am fairly new to the intentions of passing contexts downstream to other methods and functions. I understand how a context works, how it is used, how it holds its values, how it's related ...

Background: I've starting building a Go web app. While working on setting up CSRF handling I noticed that variables remain set after the request has finished. For example, I was using variables for ...

My question is about a design choice for the Context interface. If I want to create a child context from a parent I can do something like: child, cancel := context.WithTimeout(parent, timeout) ...

I'm trying to protobuf, already installed. I installed the plugin by - go get -u github.com/golang/protobuf/protoc-gen-go and it gives me output- Output of go get But I can't seem to create any ...

I have one Go HTTP handler like this: mux.HandleFunc("/test", func(w http.ResponseWriter, r *http.Request) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() if cn,...

I have a config file in YAML format, which I am trying to output as JSON via an http API call. I am unmarshalling using gopkg.in/yaml.v2. Yaml can have non-string keys, which means that the yaml is ...

I have a ReactJS based Website with GO has Webserver/Backend with a REST API approach. At least this is how it would run on a normal dedicated server. I'm trying to move the project to the Google ...

while using cgofuse i cant create dir inside mounted fs with os.Mkdir: panic: mkdir mp/testDir: input/output error Code: import ( "fmt" "os" "path/filepath" "syscall" "...

When running the go build command on IBM cloud, it's getting error # # github.com/hyperledger/fabric/vendor/github.com/miekg/pkcs11 exec: "s390x-linux-gnu-gcc": executable file not found in $PATH ...

Using sqlx with a couple concurrent connections I ran quickly into the issue of Too many open connections. Limiting db.DB.MaxOpenConnections got actually rid of the problem and activated the ...

How do I send the post in GoLang? I have the following code in ruby, now I need to transfer into Golang. http = Net::HTTP.new('example.com', 443) http.use_ssl = true http path = '/abc/login' data = ...

I am new to mgo and would need some help with this: I can succesfully connect and print out db name, collection name and number of item is collection, but do not know how to print out contents in it ...

For Client applications using fabric-sdk-go we use config.yaml and we specify urls or peer and orderer(s) to connect to Something similar to https://github.com/hyperledger/fabric-sdk-go/blob/master/...

Extracting substrings in Go

5 answers, 61.662 views go go
I'm trying to read an entire line from the console (including whitespace), then process it. Using bufio.ReadString, the newline character is read together with the input, so I came up with the ...

I was trying to install Fabric SDK go, but when I give 'make' command it throws an error cd SGOPATH/src/gtthub.com/hyperledger/fabrtc-sdk-go ; > make All files have SPDX-Ltcense-Identtfter ...

I am making a graphics page using andlabs ui. I want to increase length of seearch box. How can we increase it? How can we increase box length and set box height and width? package main import ( ...

This is a C struct that I want to port into Go struct: struct InputBuffer_t { char* buffer; size_t buffer_length; ssize_t input_length; }; But there is a way to declare buffer_length ...

Using the Go SQL library we can create SELECT, INSERT, UPDATE and DELETE statements with parameters like this: db.Query("SELECT * FROM database.table WHERE param = ?", param_value) I want to create ...

How do I add a custom delimiter to iris templates? I'm using angularjs for the front end and it conflicts with what angularjs is doing. I found some reference here but when I tried, it doesn't work, ...

I am trying to range through a slice of structs in iris the golang web framework as follows. type prodcont struct{ List []Post } type Post struct{ Id int Title string Slug string ...

I'm new in Golang, I've been doing some code tests to build an REST API using Iris framework, I'm trying to get the body data from a Post to my API but I cannot make it works, I did read the Body ...

I'm trying to get iris (http://iris-go.com) to serve both /api/ routes and host an angular SPA (in html5 mode). package main import ( "github.com/kataras/iris" // "github.com/kataras/iris/...

I started using Golang's Web Framework (Iris). I'm using the official iris book from gitbooks. I'm working on the last example in this page from the book. Following is the code used in the last ...

We are looking to control the linux (RHEL) process (e.g. Tomcat ) using REST End POINT at OS Level. With End Point, we need to see if the process is running (or) shutdown Stop the process Start the ...

Ok, so first of let me start off by saying I know that with go I should really go for the net/http framework unless I have the knowledge to write my own or I explicitly tried that and it didn't work. ...

Anybody able to wire Golang's ReverseProxy functionality with Iris-Go web framework. I couldnt make it working. I am able to wire it with regular net/http. func MultiHostReverseProxy(targets map[...

I've swapped an endpoint from our PHP 7 app to a new Go service. The service takes a geographic bounding box and returns properties from a mongo database. The problem is that it's currently taking 4-5 ...

I want to get the query arguments from RequestURI in golang. The URL is like that: http://localhost:3000/add-ebay?authToken=AgAAAA**AQAAAA**aAAAAA**6d8JWQ**nY+sHZ2PrBmdj6wVnY+sEZ2... And my code is ...

http://127.0.0.1:8080/x?haha=1 I want to get something like ctx.QueryArgs().Get("haha") is it possible in golang's fasthttp package?

I tried to get all headers in handler and faced some difficulties. valyala/fasthttp has the needed methods and I can get headlines one by one, but I don`t see the obvious way to get all of the ...

Is there any way to serve multiple directory using fasthttp framework? I wrote the below code for the same purpose. But, this code is not working as I expected. When I access localhost:8080/path1, It ...

The package valyala/fasthttp implements the following function type: type RequestHandler func(ctx *RequestCtx) It is used in buaazp/fasthttprouter like this: func (r *Router) Handle(method, path ...

I am getting below error while compiling multiple-value selection.Text() in single-value context var selection *agouti.Selection s1 := a.page.FirstByXPath(`//*[@id="name"]`) selection = s1 ...

What is the standard way to organize Go code in a repo that also contains scripts from other languages? It seems like you are intended to just have one directory for all of your Go projects, with ...

I have this dockerfile FROM golang:1.10.2-alpine3.7 AS builder RUN apk add -U git COPY . /go/src/github.com/italojs/ms-crop-image WORKDIR /go/src/github.com/italojs/ms-crop-image/app RUN go get -u ...

When is the init() function run?

9 answers, 100.600 views go go init
I've tried to find a precise explanation of what the init() function does in Go (Golang). I read what Effective Go says but I was unsure if I understood fully what it said. The exact sentence I am ...

I want to capture the Ctrl+C (SIGINT) signal sent from the console and print out some partial run totals. Is this possible in Golang? Note: When I first posted the question I was confused about Ctrl+...

In golang, how do you assign a default value if an environment variable isn't set? In python I could do mongo_password = os.getenv('MONGO_PASS', 'pass') where pass is the default value if MONGO_PASS ...

I have a package collision where I get the following error: mockgen -package=mocks -source=myproto.pb.go -destination=mocks/my_mocks.go imported package collision: "foo" imported twice I see one ...

I need to create a function that: returns true if all elements in a slice are equal (they will all be the same type) returns false if any elements in a slice are different The only way I can think ...

Is there a way how I can call golang functions from jsonnet? Now that there is a go port of jsonnet and for example ksonnet is adding custom native functions I am wondering if there is a way how to ...

In Go, can a single line of input be read from stdin in a simple way, which also meets the following requirements? can be called by disparate parts of a larger interactive application without having ...

Related tags

Hot questions

Language

Popular Tags