We are also web developers on those stacks.
We are also web developers on those stacks.
I mean, tell me the equivalent Java code to this:
resp, err := http.Post("http://example.com/upload", "image/jpeg", &buf)
I think that would be about 20 lines in Java. You've got to make a `HttpUrlConnection`, then call `setDoInput(true)` (or is that `setDoOutput(true)`), wrap it in a `try`, etc. etc. etc.Go's standard library is amazing.
Nothing prevents you to wrap those 20 lines in a generic method.
Also there are other options in Clojure, Scala, Kotlin, Groovy besides pure JDK API calls. Here Scala style, easy to mimic in Java 8
val result = http.postData("http://example.comupload").header("Content-Type", "image/jpeg").responseCode
> Go's standard library is amazing.So amazing that is doesn't have proper database drivers for the SQL databases that matter.
Not community projects that kind of work.
ws.url("http://example.comupload").withHeaders("Content-Type" -> "image/jpeg").post()
Also this is non blocking, while the go code will bock, by default. there is even akka-http now which could be wrapped really great which is streamed by default, even better.The point is Go's library already has all the nice convenience methods. With Java I would be endlessly writing them myself, and even then they wouldn't be as good as Go's because they wouldn't be standard (no help on StackOverflow for example).
Also many Java bashers in the Go community seem to be unaware of what is delivered in the JDK.
When I used to daily read gonuts, many weren't even aware that since Java 6, there is a similar infrastructure for HTTP(S), no need for third party servers.
Request request = new Request.Builder()
.url("http://example.com/upload")
.post(RequestBody.create(IMAGE_JPEG, file)
.build();
Response response = new OkHttpClient().newCall(request).execute();
But yes Go's standard library is cool, but Java's ecosystem is too, and larger.