You should use gometalinter to check your code for warnings/suggestions. That will help you write better code and you’ll know where your code is erroring out. I use vim-go to have this integration in my editor itself.
I ran your code against gometalinter and this is what I have. ➜ $?=0 /tmp/temp [10:28AM] % gometalinter --enable-all main.go:22::warning: line is 1388 characters (lll) main.go:22:194:warning: "ridiculus" is a misspelling of "ridiculous" (misspell) main.go:16:7:warning: exported const TestDataCount should have comment or be unexported (golint) main.go:26:9:warning: error return value not checked (f.Write([]byte(data))) (errcheck) main.go:20::warning: Errors unhandled.,LOW,HIGH (gas) main.go:26::warning: Errors unhandled.,LOW,HIGH (gas) main.go:10:6:warning: func random is unused (U1000) (unused) main.go:10:1:warning: random is unused (deadcode) >>> 6s elasped... ➜ $?=1 /tmp/temp [10:28AM] % On Wed, Jun 28, 2017 at 12:56 AM, <[email protected]> wrote: > I am running the following program: > > package main > > import ( > "math/rand" > "os" > "gopkg.in/cheggaaa/pb.v1" > ) > func random(min, max int) int { > return rand.Intn(max - min) + min > } > var data = "" > const TestDataCount = 20000 > func main() { > bar := pb.StartNew(TestDataCount) > f,_ := os.Create("HelloWorld.txt") > for i := 0; i < TestDataCount; i++ { > data = data + "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. > Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque > penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec > quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla > consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, > vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis > vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer > tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate > eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend > ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. > Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. Aenean > imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies > nisi. Nam eget dui. Etiam rhoncus. Maecenas tempus, tellus eget condimentum > rhoncus, sem quam semper libero, sit amet adipiscing sem neque sed ipsum. > Nam quam nunc, blandit vel, luctus pulvinar, hendrerit id, lorem. Maecenas > nec odio et ante tincidunt tempus. Donec vitae sapien ut libero venenatis > faucibus. Nullam quis ante. Etiam sit amet orci eget eros faucibus > tincidunt. Duis leo. Sed fringilla mauris sit amet nibh. Donec sodales > sagittis magna. Sed consequat, leo eget bibendum sodales, augue velit > cursus nunc,\n" > bar.Increment() > } > bar.FinishPrint("The End!") > f.Write([]byte(data)) > } > > and once the variable data gets to a certain size, the program just halts. > I have been experiencing this problem with a number of variables I am > working with while programming,* and this as never been a problem until > today. *Did I change something with my environment that causes the > program to pause when it it encounters large variables? There is no error > encountered, the progress bar just stops progressing for an indefinite > period of time. > > $go env: > > GOARCH="amd64" > > GOBIN="" > > GOEXE="" > > GOHOSTARCH="amd64" > > GOHOSTOS="darwin" > > GOOS="darwin" > > GOPATH="/Users/kacquah/go" > > GORACE="" > > GOROOT="/usr/local/go" > > GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64" > > GCCGO="gccgo" > > CC="clang" > > GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments > -fmessage-length=0 -fdebug-prefix-map=/var/folders/rw/ > y6pvhwns1ll84hmqj713bhts3lrtvf/T/go-build011121998=/tmp/go-build > -gno-record-gcc-switches -fno-common" > > CXX="clang++" > > CGO_ENABLED="1" > > PKG_CONFIG="pkg-config" > > CGO_CFLAGS="-g -O2" > > CGO_CPPFLAGS="" > > CGO_CXXFLAGS="-g -O2" > > CGO_FFLAGS="-g -O2" > > CGO_LDFLAGS="-g -O2" > > > Thanks, > > Ken > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- Cheers, Abhijeet Rastogi (shadyabhi) -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
