eclipse-scala-go

eclipse-scala-go


1 answer

Count all amount of numbers in 2d array

I'm trying to write console minesweeper, but cant figure out how to iterate over 2d array, and count amount of "-1" around each of element. My array looks like [0 0 0 0 0] [0 0 -1 0 0] [0 0 0 0 0] [0 ...

1 answers | 4 mins ago by Avdept on Stack Overflow stackoverflow.com
1 answer

How do you copy a file in Go?

I have the following function to copy a file (io.Reader actually) to the destination string location. However, it seems only part of the file is actually copied resulting in a corrupt file. What am I ...

1 answers | 34 mins ago by Xeoncross on Stack Overflow stackoverflow.com
1 answer

How to obtain Docker image ID from API after building?

According to the Docker v1.18 API documentation, the /build method accepts a TAR stream (with a Dockerfile) and attempts to build the image. However, unless I'm missing something, there seems to be ...

1 answers | 49 mins ago by Nathan Osman on Stack Overflow stackoverflow.com
2 answers

Is there a package to marshal in and out of x-www-form-urlencoding in golang

I would like to marshal in and out of x-www-form-urlencoding similar to how you can do it with json or xml. Is there an existing package to do this, or are there any documents on how to implement one ...

2 answers

Why can't I add a body to an http redirect?

Here is what I've tried: w.WriteHeader(301) w.Write([]byte("Redirecting...")) w.Header().Set("Location", "/myredirecturl") w.Header().Set("Content-Length", contentLength) // I thought this might help ...

2 answers | 3 hours ago by funerr on Stack Overflow stackoverflow.com
1 answer

Why can't the interface be implemented with pointer receivers

I'm confused as to why this fails to compile with: impossible type assertion: Faz does not implement Foo (Bar method has pointer receiver) if I make the receiver for Faz.Bar a ...

1 answers | 4 hours ago by 0xor1 on Stack Overflow stackoverflow.com
1 answer

How to check if a file is a valid image?

I am building a web application. On one of the pages there is an upload form, where user can upload a file. After the upload is done, I want to check on the server if the uploaded file is an image. ...

1 answers | 5 hours ago by Dmitry Papka on Stack Overflow stackoverflow.com
3 answers

Silence user input in Scan function

How do I hide user input (password field) in terminal similar to the -s command in read -s p "password " password in bash. ? var password string fmt.Println("password: ") fmt.Scan(&password) ...

3 answers | 6 hours ago by user3918985 on Stack Overflow stackoverflow.com
1 answer

Go: Interface method override from embedded structure

Consider the following code: type Intf interface { Method() } type TypeA struct { TypeBInst Intf } func (*TypeA) Method() { log.Println("TypeA's Method") } func (t *TypeA) Specific() { ...

1 answers | 6 hours ago by Ganitzsh on Stack Overflow stackoverflow.com
3 answers

Get a list of all installed packages in Go

How can I list all installed packages via goinstall? I need this to reinstall all packages installed on one computer to a different computer.

0 answers

In Go, is there an os-independent way to atomically overwrite a file?

If the file already exists, I want to overwrite it. If it doesn't exist, I want to create it and write to it. I'd prefer to not have to use a 3rd party library like lockfile (which seems to handle all ...

1 answer

kafka consumer group expired?

Immediately after I commitoffset using the golang client. https://github.com/Shopify/sarama ./kafka-consumer-offset-checker.sh --zookeeper=localhost:2181 --topic=my-replicated-topic --group=ib ...

1 answers | 9 hours ago by onfire on Stack Overflow stackoverflow.com
1 answer

Insert nested data into BigQuery using Golang

I can insert a flat object into BigQuery using Golang - how I can insert nested data into a table? My BigQuery schema looks like this (from the example): [{ "name": "kind", "mode": ...

1 answers | 9 hours ago by simonmorley on Stack Overflow stackoverflow.com
2 answers

How can I compare two source code files/ ast trees?

I'm generating some source code using the templates package( is there a better method? )and part of the testing I need to check if the output matches the expected source code. I tried a string ...

1 answer

Store 2 values in one variable

Is this Go code correct and portable, I need to store 2 counters (each call only one counter will be updated) in one variable to avoid locks in actual code where I am going to use single ...

1 answers | 13 hours ago by Alex on Stack Overflow stackoverflow.com
2 answers

Why declare like “var _ I = T{}” and “var _ I = &T{}” continuously in golang?

When I read a copy of the docker/distribution source code, I find there are variables declared which make me quite confused. The code is: var _ FileInfo = FileInfoInternal{} var _ FileInfo = ...

2 answers | 14 hours ago by JCheng on Stack Overflow stackoverflow.com
1 answer

GoLang Heap and Heapsort

So I'm trying to implement a max heap for practice so I can get familiar with Go. type MaxHeap struct { slice []int heapSize int } func BuildMaxHeap(slice []int) MaxHeap{ h := ...

1 answer

Main thread never yields to goroutine

edit * -- uncomment the two runtime lines and change Tick() to Sleep() and it works as expected, printing one number every second. Leaving code as is so answer/comments make sense. go version ...

1 answers | yesterday by LanceH on Stack Overflow stackoverflow.com
1 answer

Mapping all routes and its http methods in Goji

I would like to map each route and it's request type (GET, POST, PUT, ...) to generate something like a sitemap.xml in JSON for my restful API. Goji uses functions to create a new route. I could ...

1 answers | yesterday by user3147268 on Stack Overflow stackoverflow.com
1 answer

Handling multiple errors

I have Function 1: func Function1() { if err := Function2(); err != nil { } } and Function2: func Function2() error { if err := doSomethingThatMightCauseError(); err != nil { ...

1 answers | yesterday by tommyd456 on Stack Overflow stackoverflow.com
0 answers

GoProxy SSL interception in golang

I am trying to block requests to anything over HTTPS It works perfectly for HTTP, however HTTPS seems able to completely avoid my proxy. I am using foxyproxy in firefox to set it to use my proxy. ...

1 answer

Golang - 0 not as null

I am passing values to a struct in which the value has omitempty Offset uint64 'json:"offset,omitempty"' However when I pass 0 as the value of offset it is also omitted. Can I somehow declare 0 ...

1 answers | yesterday by Elliot Reeve on Stack Overflow stackoverflow.com
2 answers

How to avoid re-implementing sort.Interface for similar golang structs

There is one problem bothering me in Golang. Say I have 2 structs: type Dog struct { Name string Breed string Age int } type Cat struct { Name string FavoriteFood string Age int ...

2 answers | yesterday by Lich on Stack Overflow stackoverflow.com
1 answer

Communicating with hiveserver2 using Golang

I have hortonworks HDP sandbox installed inside Oracle Virtual Box. And I've given access to port 10000. In hive configurations hiveserver2 thrift port is set to 10000 also. I'm using ...

1 answers | yesterday by PrasadJay on Stack Overflow stackoverflow.com
1 answer

setting a variable from test file in golang

i'm trying to set a variable from my unit tests file main_test.go var testingMode bool = true main.go if testingMode == true { //use test database } else { //use regular database } If I ...

1 answers | yesterday by Allen on Stack Overflow stackoverflow.com
1 answer

How to store object in a struct

I'm not sure how to create a struct to store a JSON object that is being posted to my API. The JSON looks like this: { "name" : "Mr Robinson", "email" : "test@test.com", "username" : ...

1 answers | yesterday by tommyd456 on Stack Overflow stackoverflow.com
1 answer

How to use goroutine inside AppEngine?

I'm using Cloud Endpoints and Go and I'm trying to call a method in asynchronous way by using a goroutine. When I'm running the following code locally I can see the debug prints but on the server it ...

1 answer

Golang HTTP POST using HTTP/1.0

Is it possible to send HTTP requests using HTTP/1.0 with golang? I tried the following: req, _ := http.NewRequest("POST", url, buffer) req.Proto = "HTTP/1.0" client := &http.Client{} resp, err = ...

1 answers | yesterday by plithner on Stack Overflow stackoverflow.com
3 answers

POST params with spaces in it

How do I make a POST request when the post param has spaces in it? Eg. in bash I would do this: curl -X POST "https://website.com/api" --data-urlencode "key=$SSHKey" <- "ssh-rsa abcde abc@abc.com" ...

3 answers | yesterday by user3918985 on Stack Overflow stackoverflow.com
1 answer

Why this go code output like this?

I'm learning Go langue in here, and I modify a little code like this, I add a sleep(2s) before quit <- 0, and output index of fibonacci with i, below is my code: package main import "fmt" import ...

1 answers | yesterday by MoreFreeze on Stack Overflow stackoverflow.com
15 30 50 per page
1 2 3