Search the Community
Showing results for tags 'go'.
-
I was programming my interpreter in Go. I wrote some tests for my parser, and it bugs out with a spectacular error. I could not get an answer to my problem on SO+Discord. the test: func TestLetStatements(t *testing.T) { input := ` let x = 5; let y = 10; let foo = 83; ` l := lexer.New(input) p := New(l) program := p.ParseProgram() if program == nil { t.Fatalf("ParseProgram returned nothing") } if len(program.Statements) != 3 { t.Fatalf("statement shouldn't have more than 3 statements. Got %d", len(program.Statements)) } tests := []struct { expectedIdentifier string }{ {"x"}, {"y"}, {"foo"}, } for i, tt := range tests { if !testLetStatement(t, program.Statements[i], tt.expectedIdentifier) { return } } } The lexer.New function basically lexes the current and the next token(peeking for != and == etc) and New is just for parsing the said tokens. The function basically has to match the identifiers, and test let statements, ie: let x = 57; The error I receive is: --- FAIL: TestLetStatements (0.00s) panic: runtime error: invalid memory address or nil pointer dereference [recovered] panic: runtime error: invalid memory address or nil pointer dereference [signal 0xc0000005 code=0x0 addr=0x18 pc=0x6b555d] I am running this on Debian x86 and I couldn't follow the lead of my debugger, PS: Please add go syntax highlighting to code blocks.
-
package main import ( "database/sql" "fmt" "log" _"github.com/go-sql-driver/mysql" ) func main() { db, err := sql.Open("mysql", "SQL CONNECTION") defer db.Close() if err != nil { log.Fatal(err) } result, err := db.Query("SELECT post_id,author FROM posts;") if err != nil { panic(err) } for result.Next() { var post_id string var author string var count int err = result.Scan(&post_id, &author) if like := db.QueryRow("SELECT COUNT(post_id) as count FROM rating_info WHERE post_id = '?' AND rating_action = 'like'",post_id).Scan(&count); if err != nil { fmt.Println(fmt.Sprintf("%#v", err)) panic(err) } fmt.Printf("Id: %d Name: %s\n", post_id, author) fmt.Println(like.Scan(count)) fmt.Println(like) } // database object has a method Close, // which is used to free the resource. // Free the resource when the function // is returned. defer db.Close() } end goal: I want to use like.count, how can i do this in GOLANG (coming from PHP?)
-
Hey, boys! I play CS:GO a lot, but throughout the last year my FPS has been dramatically reduced for some reason. I concluded that it must be the GPU (Radeon 290), so I bought myself a GTX 1080. It not only didn't help, but the FPS seems lower than before. I've read that AMD cards run CS:GO better, but still.. On Inferno my average FPS is around 130, but in some areas it can dip as low as 90 consistantly. (Offline, no bots) It's a bit better on other (older) maps, but is still not great. I've tried everything thinkable on the software side to fix this problem, like: - Updating all drivers (made no difference) - Changing Nvidia settings to high performance (made no difference) - Lowering my CS:GO video settings (tried all combinations, but made close to no difference) - Several Launch options and console commands for CS:GO (made no difference) - Closing all applications other than Steam and CS:GO (made no difference) - Overclock my CPU with MSI "OC Genie" (made noticable difference other than PC crashes) The only thing which isn't high end in this build is my CPU, do you guys it would help to upgrade it? I've read some places online that CS:GO is quite CPU reliant, but I don't really know. Current specs: Motherboard: MSI Z97 GAMING 5 CPU: Intel i7-4770k GPU: ASUS GeForce GTX 1080 ROG Strix Gaming PSU: Corsair HX850i 850w RAM: 32GB Hyper X DDR3 MHz OS SSD: Samsung SSD 840 EVO 120GB OEM HDD: WD Desktop Black 3TB Windows 10 home 64bit CPU Cooler (AIO watercooling): Corsair H100i Hydro Series CPU cooler BOIS Version: 1.00 Thanks for any advice! ps: I know this build is unbalanced and not "value friendly". It has it's reasons .
-
So I've bought a new Samson Go mic, and it doesn't work with Discord or Skype. It is working though on voice recorder (Windows 10 built in voice recorder) and in games like Overwatch and CS:GO. I've plugged in my mic to other computers and it seems to work just fine with Discord and Skype. (Also whenever I plug in the microUSB end into the mic I can't hear any of the conversation). Any ideas?
-
Not to long ago, there was a Pokemon Go even held in Chicago, where there were about 20,000 attendees. All of them were not able to sign on to the Pokemon Go servers in order to play the game, so all they did was went there for nothing. Now one dude has filed a class action lawsuit in California, for unspecified amount of damages. PDF https://arstechnica.com/wp-content/uploads/2017/07/Pokemon-Go-Complaint.pdf Article https://arstechnica.com/tech-policy/2017/07/pokemon-go-fests-blunders-result-in-class-action-lawsuit/
-
Hi, so I am looking for a new language to learn, I have been programming in C# for the past 4 years. I found that Go language is becoming more popular and I quite liked its features as well. Is Go language used also professionaly in real world applications or is it just a language for making simple hobby programs? Is it even a good idea to learn Go?
-
I want to make a montage of some cool clips from professional cs:go matches. For example, some famous KennyS shots, well known clips in general, or any other impressive play. How can I find these match id's so I can download them through cs:go and take cinematic shots? I cannot find any id's on google or from any friends. Please either help me by sending me match id's from professionals, well known clips, impressive clips, or provide me with a way to find match id's like this.
-
Hey everyone, I am copying a file using Go and must make sure that the buffer size of my last block matches the source file exactly, not extending the new file any longer. The files must be identical. I have a working program, I only need help with changing the buffer size for the last block. "One common mistake made by students is that they forget to consider the last block situation. Because a file can be of any size, the last block MIGHT NOT be filled to the very end. As a result, you need to write ONLY the number of bytes that are available in the last block." I have the code working, but I can't figure out how to change the buffer size. package main import ( "fmt" "io" "log" "os" "path/filepath" ) //BSIZE is the size of the buffer var BSIZE int64 = 4096 var err error = nil func main() { if len(os.Args) != 3 { fmt.Printf("usage: %s source destination \n", filepath.Base(os.Args[0])) os.Exit(3) } //open the source file source, err := os.Open(os.Args[1]) if err != nil { fmt.Println("Error opening file...") log.Fatal(err) } //check to make sure the destination file does not already exist _, err = os.Stat(os.Args[2]) if err == nil { fmt.Println("Destination file already exists.") log.Fatal(err) } //create destination file destination, err := os.Create(os.Args[2]) if err != nil { log.Fatal(err) } //actual copying of the file buf := make([]byte, BSIZE) for { n, err := source.Read(buf) if err != nil && err != io.EOF { log.Fatal(err) } if n == 0 { break } if _, err := destination.Write(buf[:n]); err != nil { log.Fatal(err) } } //close the files defer source.Close() defer destination.Close() }
-
Hello, I am trying to get an assignment wrapped up for school and can't figure out how to make this command line calculator work. I am trying to have it accept input from the user to determine whether or not it should repeat or end, and it completely stalls and I have to ^C to get it to stop. Any ideas? package main import ( "fmt" _ "fmt" "os" //"sort" ) func main() { fmt.Println("\n*****************************************************") fmt.Println("**** Welcome to the world's best CLI calculator! ****") fmt.Println("*****************************************************") fmt.Println("\n\nLet's get started!") var a, b, c int = 1, 1, 3 var operator, resume, valid string = "", "y", "n" for c == 3 { fmt.Println("Please enter your first int: ") _, err := fmt.Scan(&a) if err != nil { fmt.Println("Invalid;", err) os.Exit(0) } fmt.Println("Please enter your second int: ") _, err2 := fmt.Scan(&b) if err2 != nil { fmt.Println("Invalid;", err2) os.Exit(0) } fmt.Println("Please choose your operator (+ - * /): ") _, err3 := fmt.Scan(&operator) if err3 != nil { fmt.Println("Invalid;", err3) os.Exit(0) } //Choose an operator. switch operator { case "/": fmt.Println("Your equation is ", a, operator, b, "=", a/b, ". \nWould you like to go again? (y/n): ") case "*": fmt.Println("Your equation is ", a, operator, b, "=", a*b, ". \nWould you like to go again? (y/n): ") case "-": fmt.Println("Your equation is ", a, operator, b, "=", a-b, ". \nWould you like to go again? (y/n): ") case "+": fmt.Println("Your equation is ", a, operator, b, "=", a+b, ". \nWould you like to go again? (y/n): ") default: fmt.Println("Invalid input.") } _, err4 := fmt.Scan(&resume) if err4 != nil { fmt.Println("Invalid;", err4) os.Exit(0) } //Do we repeat the process? for valid == "n" { switch resume { case "y": valid := "y" _ = valid case "yes": valid := "y" _ = valid case "yeS": valid := "y" _ = valid case "yES": valid := "y" _ = valid case "yEs": valid := "y" _ = valid case "Y": valid := "y" _ = valid case "Yes": valid := "y" _ = valid case "YeS": valid := "y" _ = valid case "YEs": valid := "y" _ = valid case "YES": valid := "y" _ = valid case "n": valid := "y" _ = valid case "N": valid := "y" _ = valid case "no": valid := "y" _ = valid case "No": valid := "y" _ = valid case "nO": valid := "y" _ = valid case "NO": valid := "y" _ = valid default: fmt.Println("Invalid input. Calculate again? (y/n): ") _, err5 := fmt.Scan(&resume) if err5 != nil { fmt.Println("Invalid;", err5) } } } } }
-
Hey, so I am trying to setup Go on my linux server so I can run a go script with it. But there seems to be a problem. When I try to type "go run the-package-name", it returns this error: package discord-image-downloader-go is not in GOROOT (/usr/local/go/src/discord-image-downloader-go) Here are my go variables: GO111MODULE="" GOARCH="amd64" GOBIN="" GOCACHE="/root/.cache/go-build" GOENV="/root/.config/go/env" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOINSECURE="" GONOPROXY="" GONOSUMDB="" GOOS="linux" GOPATH="/root/work" GOPRIVATE="" GOPROXY="https://proxy.golang.org,direct" GOROOT="/usr/local/go" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64" GCCGO="gccgo" AR="ar" CC="gcc" CXX="g++" CGO_ENABLED="1" GOMOD="/var/samba/DiscordDownloader/discord-image-downloader-go-master/go.mod" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build402659142=/tmp/go-build -gno-record-gcc-switches" It's probably a really easy solution, but I am not seeing it. If anyone can help, that would be amazing. Thanks!
-
So I bought the Surface Go 64GB version with 4GB of RAM. Now I Realize that was a mistake even thought I thought I could get away with 4GB cause of the video Linus made about RAM usage and how 4GB is enough for web browsing and 8GB is good all round with 16GB being near overkill but better for gaming and content creation. I have the tools to remove the current RAM chip in the Surface Go and solder an 8GB or even 16GB chip. My question is do I need to flash the chip or Surface Go at all or will it automatically recognize the RAM and work. Any help is appreciated.
-
The Surface Go made to be a cheap alternative to the surface lineup for student and those on a tight budget, but does it give you what you expect for $399.99. Well kinda, I have the $399.99 model with 64GB of storage and 4GB of ram and its been great, at least the second one has, but I’ll get to that later. For now let’s take a minute to talk about the tablet. I call it a tablet because it’s sold as one with no keyboard, mouse or pen. As a tablet it’s crap, the on screen keyboard needs work and fails to be comfortable to use. windows 10 is no were near 8.1 in terms of tablet usability. Now once you pay another $99.99 for the keyboard, which is now $129.99, you're already paying a hefty price for what could be a better laptop. That being said, I’m going to keep mine. I’m sorry Microsoft, I’m not giving this loner back. I fell in love with it from day one for its small size and great battery. It easily gets me through the day of lectures and then some when I get back to my dorm for some Netflix, but that doesn’t mean it's great for productivity. I've yet to have page file errors in Edge but I do see ram hit max usage after 10 tabs, so as long as you aren't like Linus with his 50 tab addiction you should be fine. But I think it gets away with this as it ships with windows 10S so you can’t install anything that isn't on the Microsoft store app. So if you love chrome like me, it will take a while to learn to love edge, but it's worth it for me as all my work is done with google docs anyway. Now about this being my second version, I’d like to say that I had a hard time my first week with this device. My first model suffered from the sleep of death which was the first case Microsoft saw on this model. I told them about it, and they were quick to replace it but I would have to send it in and wait on a new model in the mail. So I drove 2 hours to the nearest store and had it swapped there. It was a setback, but I think they understood because they gave me free goodies and a voter card to the store. Good job on rectifying the problem and making it up to the customer, although a gas card would have been nice because the drive made me use a quarter of a tank of gas and I missed 2 classes that day. Although it was well worth it. The small 64GB SDD hasn't been a problem as the first day I had it I went and got a nice 128GB SD card that slipped nicely into the back of the device under the kickstand. Speaking of which the kickstand is really nice and has the perfect amount of restrictiveness and angles of tilt. Microsoft did a great job on the looks and feel of the device right down to the charger which is a magnetic reverse able connecter, nice touch to bad Apple dropped that for some reason. All in all I would recommend this device highly to any student or light user with almost no hesitation as it’s the nicest “laptop” at its, all be it a little higher than I’d like, price tag.
- 12 replies
-
- review
- surface go
-
(and 2 more)
Tagged with:
-
I'm looking for anyone here who uses Google's Go programming language (commonly referred to as Golang) that might be interested in helping out with some projects of mine (especially if you use Discord and like Discord bots, I'm looking for you guys :D), or even just anyone who uses the language that likes sharing ideas and experiences with using the language. I always see things about C/C++ or Java or other languages, but never anything about the late-coming language that many people seem to have never heard of yet end up loving it when they find out about it (like me!). For those who don't know, Go is an assembly-compiled language created by Google that runs on various architectures and in various operating system environments. I've used it for multiple purposes to date, such as my Discord bot Clinet and an in-development networking protocol called Lilac (which runs atop the IP protocol and alongside TCP/UDP and other networking protocols, also not yet available due to its alpha state). Chances are, if you can do it in C or C++, you can do it in Go, and that on top of the easier-to-understand syntax is what drove me to try it out and wind up loving it in the end. Hope to see some Gophers around here soon~!
-
Fast way to boost fps on csgo when using an intel hd 4600
YourNewPalAlex posted a topic in PC Gaming
Any good way to boost performance on csgo when using an intel hd 4600, backstory, my main dgpu got burned on my laptop from overuse so for the time beeing im stuck with an i5-4210H and an intel hd 4600. When lowering the res to 1280x720 i get playable 34-40fps for like 5min then it stays at like 33fps which is playable. Now i know i can try autoexec.cfg but ive tried alooot of them and almost everyone is crappy and outdated. Ive tried steam launch options, same thing, so heres the part where i want help from you! Comment any suggestions that might help me out, appreciate it alot. -
As the title implies, I'm working on trying to read input from a user (The file name) then use that input to open the file. For some reason if i put the file name in manually "myfile.txt" it will open but when using the variable it is stored to userinput it will not open reader := bufio.NewReader(os.Stdin) fmt.Print("Enter text: ") userinput, _ := reader.ReadString('\n') fmt.Println(userinput) file, err := os.Open("myfile.txt") //need to get this to take a userinput (Currently gives an error when trying os.Open(userinput)) if err != nil { log.Fatal(err) } defer file.Close() scanner := bufio.NewScanner(file) for scanner.Scan() { fmt.Println(scanner.Text()) //need to get this into an array seperated by spaces (Currently reads line by line) } this is currently what I have, os.Open is the preferred way id like to do this (mostly because i already have the scanner set up) but I'm more than happy to change code if anyone can help me with this issue. Thanks
-
This will be long, while I'd love a shoutout in the video to know the team saw this, I'd settle with seeing my points in the review. I got this... Yesterday. And my feelings are... mixed. Let's start with pros, this is light, thin, and may I say, sexy, as sexy as a macbook. The color accuracy competes with laptops 1000-2000 dollars more. And the webcam is much the same. The type keyboard being able to separate and simply walk away is a feature to love. Now to the caveats. I did say separate, while you can flip the keyboard around, didn't many of us buy this to avoid the awkwardness of pressing keys on a 2 in 1? And the battery is not 9 hours, during simple redditing and other light use, it lasts 4 hours from 100% to 10%. And while this is both a con and a pro, it ships in Windows S mode. While some people may like S, st of us will switch it, making it so that you need to wait approximately 30 minutes from turning it on for the first time to actually using it. But S mode is how it is supposed to be used, because even in browsing, the Pentium gold lags at times. I use Brave browser because while using my go, because while in Chrome the laptop lags even more. Youtube videos will stutter every 20-60 seconds. The model I got was the 4gb 128gb model from Costco, this setup is only available from Costco, It is $550 and includes the black type cover. And I bought this version, because for $500 including the type cover, the base model has an emmc 64gb storage drive and 4gb of ram, that makes that model just not sufficient, and for $650 including the type cover, the higher model becomes obviously overpriced. Because for the same price your options of traditional laptops make the performance of this one seem like a "the runt of the group" situation. I actually highly agree with Dave from Dave2D on this one, when it comes to competition, you realize that this is slow, and there are many other offerings. Or maybe you came to this device for form factor, the form is nice, small and compact. And when went to the Microsoft prior to purchase, the keyboard felt cramped, but in very little time the keyboard felt quite comfortable. The surface connector is small and often comes out of the laptop due to it's length, and the USBC has passthrough charging, which makes you ask, why doesn't this have a single thunderbolt three connector? And maybe you think you can just skip the type cover, you can't, without it, this is a paperweight, windows just isn't designed for touch, although with just the pen I could see this being used as a drawing tablet and for basic fun use, athough if you are going to type anything like this review, the type keyboard is a must, especially considering that there is no USB C dongle included to use an external keyboard.
-
Buy tampons on Amazon: http://geni.us/HHtFt Just how good is the security at the new Amazon Go store? The answer may surprise you... (but not really - it's pretty damn good)
-
I've been playing on a 1080p monitor with 4:3 black bars at a custom resolution of 1440x1080. I want to give stretched a shot but I'm not sure how to do this... Any help appriciated. I use AMD btw so please don't give me instructions for NVidia
- 2 replies
-
- aspec ratio
- monitor
-
(and 4 more)
Tagged with:
-
Original Source: http://www.overclock3d.net/news/gpu_displays/nintendo_stocks_drop_18_after_the_company_explains_that_it_doesn_t_own_pokemon/1 2nd Source: http://www.theverge.com/2016/7/25/12269466/nintendo-stock-plunge-pokemon-go Nintendo's stocks have been skyrocketing since the launch of Pokemon Go, but what if I were to say that they don't own Pokemon Go, or more to the point, if Nintendo themselves say they don't own Pokemon - what happens then? Exactly as the title says. Nintendo's Stocks have taken a sharp decrease of 18% after the company announced it doesn't own Pokemon. Let me explain, Nintendo own only 32% of the Pokemon franchise and are not a lead holder in franchise, and that they are only expected to make around 13% of all Global Pokemon Sales. Obiously, Pokemon is not the only reason for the companies stock to rise, with the announcement of products such as the Mini NES and their new console, the NX coming soon. But with this sharp fall of profits, this might only be the beginning. My thoughts? This is shocking, as I always thought of Nintendo owning all the rights to Pokemon, and not just a relatively small slice of just 32%. Either way, investors didn't take the news too well, so perhaps it is a good time to pick up some Nintendo stock (I in no way, take responsibility with recommendations for stock - this is just hypothetical, but if you want to, go for it) Your thoughts? Please leave them down below!
-
Pokemon GO is now available for U.S Field/Beta testing Everyone can sign up here, As far as i know its only available in North America specifically US. I hope this is a sign that Pokemon GO will be released globally soon! Sadly Linus and Luke, you guys have to wait a little longer. What do you guys want from this and what do you guys expect? I personally cant wait for this, I've been waiting forever and so have you guys!
-
Hey all, I wanted to get your input and discussion about Googles "Go" programming language, and whether it has any place going up against C in the embedded space. I believe there is some interesting things happening, but I don't see anyone taking Cs stronghold due to it's ubiquity. What do you think?
-
I'm a CS:GO player and I can't really choose which mechanical keyboard to get. Any ideas?
- 11 replies
-
- mechanical
- keyboard
- (and 8 more)
-
So I wanted to get into CS:GO, I have the basics of it but cant start playing until Christmas (thankfully not that far away), I understand the shooting system and all of the physics but there was a few things I wanted to know. First of all; what are the best cases to start off with? I like the look of the Karambit and Flip Knife the most, so what cases should I buy to try and get those? (I know they're rare). What cases did you start with, and what ones do you think would be most beneficial to a noob player. Can someone send me a link or explain to me what skins and knifes you get in what case? (Sending a link would probably be easiest). Also, how much are keys? If you have anymore tips that you think would be useful to me then please let me know, as I want to try and get out of Silver ASAP... Thank you for reading -Croum