Except for all the Docker stuff, this is how Caddy started. Then I wrote a for
loop that "compiled" middleware from a []func(http.Handler) http.Handler
value. It still basically does this today, and is some of Caddy's oldest code.. (The outer loop builds the middleware stack for each site on that listener, or 'group' of sites.)
Then it was time for handlers to return errors, so that error handling could be more easily coordinated among dynamic middleware stacks. So I modified the http.Handler interface to return <code>(int, error)</code> values. A simple change, but by far one of the most profound effects on Caddy: it became easily extensible, and with a simple convention, balanced correctness and usability.
Caddy doesn't use third-party middleware packages or routers. Building it all from the ground-up with the Go standard library was a lot of fun.
I ran into this blog post titled How a complete beginner learned Go as her first backend language in 5 weeks a while ago. It's both inspirational and has a great set of resources for getting started (though most already mentioned here).
Sourcegrapher here. We've gotten a ton of requests to make Sourcegraph available for more editors so folks can get instant usage examples, cross-references, and code search as they code. Didn't expect to see this WIP repository posted here before support for Visual Studio Code is released. :)
If you want to see the editors Sourcegraph supports now, or get notified when Sourcegraph supports your editor, check out or fill out https://sourcegraph.com/tools/editor?expanded=true.
They didn't:
> Within the explorer phase, you typically go through two steps. First, you ascend to the Peak of Inflated Expectations. You think you can do everything in Go, but without really understanding or grokking the Go ethos yet. […]
> Following the Peak of Inflated Expectations is the Trough of Disillusionment. You miss feature X from language Y. You haven’t fully bought into idiomatic Go. You are still trying to write in the style of other programming languages and are getting frustrated. […]
You see that you got stuck somewhere in phase 2.
Just do what the Go standard library does: lower camelCase.
E.g., https://sourcegraph.com/github.com/golang/go/.GoPackage/net/http/internal/.def/maxLineLength.
IIRC, at GopherCon, one of @bradfitz's stated regrets was that he named some of the io package constants, such as io.O_RDWR, in ALL_UPPERCASE and according to Unix conventions, not the more natural English Go conventions (which would be like io.ReadWrite). So, don't take the few instances of ALL_UPPERCASE constant naming in the stdlib as a reason to do it that way.
I didn't go into depth about cleaning up the map in the article for brevity's sake, but the connection info is removed immediately when the connection is closed or hijacked (and you're right, this is an important element, I probably should have mentioned it in the article): https://sourcegraph.com/github.com/mholt/caddy@75ccc05d840923a1dc731c569973471c5ce4654a/-/blob/caddyhttp/httpserver/server.go#L95:1-101:1
If no other Rc/Weak is pointing to the same allocation, Rc<T>
's <code>get_mut</code> provides access with &mut T
. Sourcegraph shows some usage in the wild.
Thanks for posting, @dgryski!
A few points:
I find the way Sourcegraph does things interesting. They try to make interfaces for common operations on items and reuse them throughout the different layers (for a simple web app, you might not have more than 2 layers). Check this for a proper example https://github.com/sourcegraph/thesrc
Also, you might want to read https://sourcegraph.com/blog/building-a-testable-webapp
I met the guy who was their first (and only at the time) web developer (co-founder of SourceGraph since then). He developed the whole site from scratch. They completely screwed him out of everything, his story reminded me a little of the story from The Social Network.
Add it to the list of reasons I don't visit the site
Wow, they allow quite sophisticated searches. Not only code, but commit messages too.
search shows some examples
type can be diff, commit, symbol, repo, path, file
You can write a custom type that implements driver.Valuer and db.Scanner. Here's one, for example. https://sourcegraph.com/sourcegraph.com/sourcegraph/srclib@master/.GoPackage/sourcegraph.com/sourcegraph/srclib/db_common/.def/StringSlice
Hi, idk what he means but I can tell you what I understand by it from stuff that has been discussed here before, like ProjecturED.
In the common case programming revolves about one writing a text file feeding it to a compiler that transforms that text file into an internal representation it can understand (an AST) and then manipulating it to optimize it and generate machine code. Now lets say I want to modify function foo. I modify the text file and the compiler ignores all the previous work it did before and recompiles the file from scratch.
What would be a better way? Storing code in the representation the compiler understands/manipulates and presenting it as text as a side-effect. From what I understand that is how Smalltalk works (but I am not even a Smalltalk newbie so take my word with a pinch of salt).
CL images, can also be thought as another way to store code other than text files.
The benefits can be plentiful, for example refactoring & other static analysis tools either have to work with the compiler/runtime of the language (like slime's edit-defintion and xref does afaik) or duplicate a lot of the work of the compiler, like Eclipse or sourcegraph
I hacked on this yesterday because I wanted to embed more useful code snippets in a blog, not just plaintext, unlinked snippets like Gists (or <code> tags).
It builds on a ton of stuff we've already built at Sourcegraph, much of which is open source, such as https://sourcegraph.com/github.com/sourcegraph/srclib-go and https://sourcegraph.com/github.com/sourcegraph/srclib-javascript.
I'd love to get feedback on this, and I'm happy to answer any questions anyone has about it!
It sounds interesting, but in practice we ended up hating it. This just came in: https://sourcegraph.com/blog/switching-from-angularjs-to-server-side-html
Big companies like twitter partially went back from this approach.
JSF + PrimeFaces + OmniFaces is a pretty solid approach that's easy and performs really well as a bonus.
Oh cool--this is a blog post of mine from a few months ago. We've made some improvements since this post went up: we're indexing many more Python repositories, which means more code examples, and we have better Python docs. Check out https://sourcegraph.com/github.com/django/django/docs/ref/models/fields/#django%2Fdb%2Fmodels%2Ffields%2Frelated%2FForeignKey, which are the official Django docs, and notice that all of the references to class and method names are clickable and take you to a page with semantic code examples.
I'd love to get feedback from other redditers on our Python support at Sourcegraph. Let us know here or at https://twitter.com/srcgraph!
I edited the code into the original post, ran it with `zig run src/exec.zig`.
I adapted the code from `cli.zig`and `docgen.zig`
acronis recorded and shared the all presentations as a single 1GB video.. I've downloaded the file, will split and upload to youtube - sorry it takes time.
​
in the mean time, my slides are here:
​
Although, as I'm upgrading to 1.11 I noticed kops now has integrated AWS Authentication addon, so my whole terraform configuration I go over in the presentation is most likely deprecated - yet may be useful for anyone trying to do similar tasks in the future.
​
the kops authentication config builder - https://sourcegraph.com/github.com/kubernetes/[email protected]/-/blob/upup/pkg/fi/cloudup/bootstrapchannelbuilder.go#L930
​
​
Yes, absolutely. <code>VecDeque</code> is fairly widely used, and while browsing a few of those examples I didn't find any examples of the problematic code path (reserve
or reserve_exact
followed by pushing more items) in attacker controlled input, a lot of the places where VecDeque
is used are parsers and protocols. I did find at least one use of <code>reserve_exact</code> in Xi, though it looks like it's in internal tracing code so not necessarily easy to trigger by an attacker.
The only place I've found it in the docs:
> State value for StateListDrawable, set when a view or drawable is considered "active" by its host. Actual usage may vary between views. Consult the host view documentation for details.
It is used mainly the a widget called SlidingTab in the Android source (see all uses here).
So I could be wrong, but I think it's indeed an attribute you can define to mean whatever you want in your own custom view (as D_Steve595 said).
However, it should probably be used to indicate when a view is doing something (like animating, moving, ...)?
https://github.com/mattermost/platform (a Slack-like service)
https://github.com/gogits/gogs : a GitHub/GitLab-like service
https://sourcegraph.com/ is all Go on the backend.
nitrous.io was all Go on the backend (the company is now dead but it was online IDE like Cloud9).
JavaScript is in the pipeline! you can sign up for updates here if you haven't already: https://sourcegraph.com/tools/editor?expanded=true
we'll shoot you a message when it's ready to beta test :)
Of particular interest to Gophers (beyond the fact that Sourcegraph has great support for Go): If you want to see a real-world, large Go application, check out our codebase: https://src.sourcegraph.com/sourcegraph. It has a Web app, an HTTP API, a gRPC API, database interaction, unit tests and integration tests, and a single-binary assets-included build.
It's a great way to see how we're actually building a large application in Go.
(More info at https://sourcegraph.com/blog/133554180524/announcing-the-sourcegraph-developer-release-an.)
https://sourcegraph.com/blog/live/gophercon2015/123747522610
EDIT: The questions didn't seem to make it, one of them was why HC.gov didn't work. If I'm remembering right, it was something along the lines of being overengineered and overcomplicated enterprise Java code. I think he specifically didn't blame Java the language, but the enterprise Java methodology.
As others have said, start out with net/http.
There are a lot of other sample Go web apps you can look at for inspiration, but if you want to see something a bit bigger, check out https://sourcegraph.com/sourcegraph/thesrc. It's a toy web app based on the architecture of our live site (Sourcegraph.com). There are some rough edges, but you can see how we scaled to a large app using only gorilla/mux and net/http (e.g., https://sourcegraph.com/sourcegraph.com/sourcegraph/thesrc@ed5b6d4e8d990094112494c0e6764964f655541c/.tree/app/handler.go is where we attach handlers to our previously defined router).
There is a code example with a lot of docs on what it's doing that might interest you: appdash/examples/cmd/webapp.
To expand on this a bit -- that's just the default. The data can easily be put into any type of appdash.Store, be it in-memory, on-disk, in a remote database etc.
Stephen Gutekanst and a few other folks (including myself) built Appdash as a simple way to trace and diagnose performance issues on large websites (such as ours, https://sourcegraph.com). A few other companies are using it, and I thought folks here would find it useful/interesting.
Check the README for a screenshot of the tracing UI.
It uses the terminology and design of Google Dapper (http://research.google.com/pubs/pub36356.html).
E.g., the main ID for a trace is the Span: https://sourcegraph.com/sourcegraph.com/sourcegraph/appdash@master/.GoPackage/sourcegraph.com/sourcegraph/appdash/.def/SpanID
Feedback/questions welcome!
FWIW, I don't see any usages of them in the Go stdlib, except in test cases and de/serialization.
https://sourcegraph.com/github.com/golang/go/.GoPackage/builtin/.def/complex64 https://sourcegraph.com/github.com/golang/go/.GoPackage/builtin/.def/complex128
(You can page through the references to each on the right side with the ">" button.)
Here's a list of implementations of gob.GobDecode:
(Searching for "GobDecode" will yield similar results, but this list is a bit more precise because it was actually generated using Go's interface implementation semantics.)
Sourcegraph has been on the Python and Go subreddits already, but I wanted to post it here, too. We are pushing improvements to it every day, and we'd love to hear your feedback here, @srcgraph, or at https://github.com/sourcegraph/sourcegraph.com/issues.
We've released a lot of the code behind Sourcegraph as open source at https://sourcegraph.com/sourcegraph and will be releasing more over the next few weeks. We want to let people integrate Sourcegraph into all sorts of developer tools (editors, documentation generators, etc.).
If you need IDE features and you read some specific code bases, you can generate (or request) LSIF for them and then have goto definition and hover and ... in sourcegraph. For example ripgrep does that: https://sourcegraph.com/github.com/BurntSushi/ripgrep/-/blob/crates/core/app.rs
Posting this for posterity since this is an older post but I think it could be useful.
GitHub's built-in search is pretty terrible. It's super barebones and doesn't work on branches. They're making a new one but it's not publicly available yet.
I'd recommend using something like Sourcegraph if you want to poke around the code or quickly reference something. They index (basically) all OSS projects and have a lot more powerful searching tools. Your query would look something like:
<code>repo:^github\.com/godotengine/godot$ rev:refs/heads/3.x add_color_override</code>
Awesome! I have been running a script the last 10 days and so far I have collected 1.2B videos like/dislike count (thanks to /u/jopik1 for providing a massive channel list) . I was going to post this link for anyone that wants to help with an API key since the google api examples one stops working around 4M requests.
​
p.s I do not find it correct to use them, but for anyone's interest there are more than 500 working youtube api keys (probably WAY more) publicly posted on Github.
Very interesting! There's a lot of examples of using a cloud function, but I guess there more focused on situations where there is a subcollection?, for example: https://sourcegraph.com/github.com/firebase/functions-samples/-/blob/child-count/functions/index.js?L29:37
I'm going to try what you propose, looks perfect
I am using interception-tools:
environment.etc."dual-function-keys.yaml".text = ''
MAPPINGS:
- KEY: KEY_CAPSLOCK
TAP: KEY_ESC
HOLD: KEY_LEFTCTRL
'';
services.interception-tools = {
enable = true;
plugins = [ pkgs.interception-tools-plugins.dual-function-keys ];
udevmonConfig = ''
- JOB: "${pkgs.interception-tools}/bin/intercept -g $DEVNODE | ${pkgs.interception-tools-plugins.dual-function-keys}/bin/dual-function-keys -c /etc/dual-function-keys.yaml | ${pkgs.interception-tools}/bin/uinput -d $DEVNODE"
DEVICE:
EVENTS:
EV_KEY: [KEY_CAPSLOCK, KEY_ESC]
'';
};
When using gnome also do this:
$ gsettings reset org.gnome.desktop.input-sources xkb-options
$ gsettings reset org.gnome.desktop.input-sources sources
after running sudo nixos-rebuild switch
.
On a related note, you can do text-based search over Haskell code hosted on GitHub and other code hosts in the browser using Sourcegraph. 😄 For example, here is a search for uses of head
. https://sourcegraph.com/search?q=context:global+lang:Haskell+%28%5C%28%7C+%29head%5C++&patternType=regexp
(Disclaimer: I work at Sourcegraph.)
I'm currently learning a new programming language (Swift) and it helps tremendously to have a working example of something I know sort of how to do, but where I get lost in the exact syntax. This website is great for that: https://sourcegraph.com/search?q=context:global+lang:C%23
Another tip: install a linter that warns you when you're doing things in a bad or unconventional way.
The original link has moved to here: https://sourcegraph.com/github.com/sourcegraph/openvscode-server/-/blob/doc/sourcedive.snb.md
Don't pay attention to the self-righteous ppls here, they just don't realize how incorrect they are or they wouldn't act like that.
There are 2 really easy ways of figuring these types of things out. The quickest is to use Github's advanced search and search based on the language. You can usually pull up function definitions and see how other people use the function.
The other way is to use sourcegraph.com and do the same exact thing. Search by language and just put in getParameterValue
.
You should be able to figure it out based on which libraries you're using/importing.
Personally I think GitHub's current code search solution is fairly limited, compared to something provided by Sourcegraph, for example. Also I've noticed that GitHub's code annotations could do with some work too.
I can't tell you that it makes sense, but I can at least tell you what's happening in that stack trace, so you can decide where to investigate more.
Your program was garbage collecting when you dumped the stack trace. The garbage collection was triggered by an allocation in the math/big package, during the process of checking a potential RSA private key for primality. This is a normal part of making a new certificate, so no surprises there.
While it is true that finding an RSA private key is computationally more difficult than finding an EC private key, I've never experienced a significant CPU or memory problem, not enough to hang a system and need to debug it like this. But if it's easy for you to try, you could change to using an EC key. See https://sourcegraph.com/github.com/golang/go/-/blob/src/crypto/x509/x509_test.go#L533 for an example of how the Go tests make an EC key for the P256 curve.
Was this a one-off hang, or can your reproduce it?
Good luck, tell us what you find!
I wanted to get and analyze AST, CFG+SSA, node positions and comments with performance as nikic/php-ast without requirement PHP to be installed.
I think the best purpose of using my lib is projects like SourceGraph which works with big codebases.
ps: I am a typical developer, I first do then think why)
Oh I see, thanks for the quick reply!
The conceptual distinction I was making was food processor = tool, baking sheet = supply, rolled oats = ingredient.
Here it is with your suggestions:
"tool": [ { "@type": "HowToTool", "name": "food processor", "requiredQuantity": 1 }, { "@type": "HowToTool", "name": "baking sheet", "requiredQuantity": 1 } ], "supply": [ { "@type": "HowToSupply", "name": "rolled oats", "requiredQuantity": { "@type": "QuantitativeValue", "value": 100, "unitCode": "GRM" } } ], "recipeIngredient": [ "100g rolled oats" ]
> trade-off
IMHO ease of authoring should be handled by building tools such as integrations with IDEs. People shouldn't have to write this kind of stuff without helper features like code intelligence (autocomplete, inline docs etc. – check out Sourcegraph and Tudor Gîrba's Glamorous Toolkit). Capturing reality is the whole point of having these standards. Sites and plugins are writing their own custom code to handle unit conversion for these dumb text strings. Unit conversion is not an edge case. /rant
Sourcegrapher here. We got a lot of interest on our interest form (https://sourcegraph.com/tools/editor?expanded=true) for IntelliJ, so it's definitely on our radar. If you sign up at that URL, we'll let you know as soon as it's ready!
Sourcegraph CEO here. Good news: it works on private repositories as well! Sign up at https://sourcegraph.com/, then go to My Repositories, then click the button under "Add your private repositories" to auth private repos via GitHub. It delegates to GitHub for permission checking, so it works with your existing GitHub orgs/teams/users.
Thanks for the suggestions. I also forgot godoc.org's source code:
https://github.com/golang/gddo
This article was also interesting:
The comment wasn't meant to be a negative criticism of Dave Cheney, who I think is a good guy. But you are supposed to advocate for Go, even if it's not your job. This is part of a mantra by the Go team. See the 5 stages of learning Go: https://sourcegraph.com/blog/live/gopherconindia/112025389257 . The last stage (presumably, when you have become a Go master), you are supposed to advocate. I don't particularly think that this is a good thing. But to each of his own.
Ok, got it. Sorry for not linking to it originally. Here
It is an interview with Fransesc, one of the Go team members. He answered a single question at the end where he mentioned a debugger they are working on as well as monitoring tools. I may have misrepresented the debugger. It could be that he is referring to better monitoring tools in relation to monitoring go routines.
did you read what that article said? did you bother reading what those technologies do? you just confirmed my assertion:
> My best guess is that your brain seems to have fuzzily misunderstood and re-combined "noBackend" and "single-page app" to mean "front-end web app."
Those technologies, react and flux, are front-end technologies. No one denies that. But they indeed have a backend. No one dumps everything into one file and asks "how can i trick google?"
Like I said, they are just ways to abstract away the interaction with the backend.
edit: here's an article detailing the downside of SPAs: https://sourcegraph.com/blog/switching-from-angularjs-to-server-side-html
edit2: and if you pay attention, it hints at how to solve your problem
Thanks!
BTW, only the "glue" code is written in Go. The language analysis toolchains are intended to be written in the languages they target: https://github.com/sourcegraph/srclib-javascript, https://github.com/sourcegraph/srclib-ruby, https://sourcegraph.com/sourcegraph/srclib-go, etc. (We're still porting the Python toolchain to 100% Go; still, the interesting analysis part of it uses Python.)
I'm one of the original creators. It's still alpha, so there will be bugs. But it can do some pretty cool and useful stuff already in your editor (and it powers https://sourcegraph.com/).
Anyone have feedback about how we're explaining the problem and solution, and the first-run experience of using the editor plugins and the "src" tool? We would LOVE to hear it so we can fix/improve it.
Of the 15007 uses of the only entry outside the stdlib (github.com/metaleap/go-xsd/types.OnWalkError
), 9401 uses looks to come from a single file
Waiting for someone to implement this:
https://sourcegraph.com/github.com/jashkenas/underscore/.CommonJSPackage/underscore/.def/commonjs/underscore.js/-/debounce (myFunc, 250);
Not that you should, just saying you could.
We just re-released our Ruby support, and I removed the strikethrough. It was active but unannounced for a couple of days as we ironed out some bugs. Good catch. :)
https://sourcegraph.com/blog/announcing-ruby-and-ruby-on-rails-beta