wgctrl-go icon indicating copy to clipboard operation
wgctrl-go copied to clipboard

Code examples

Open muhlemmer opened this issue 6 years ago • 2 comments

Both the client.ConfigureDevice() and client.Device() expect a non-existing wg-foobar interface, so no special tests are required like for integration tests.

Closes #37

muhlemmer avatar Mar 19 '20 22:03 muhlemmer

Fails on staticcheck, on lines not affected by this PR. Note, running staticcheck against master produces the same errors.

muhlemmer avatar Mar 19 '20 22:03 muhlemmer

I was in the misunderstanding that Go examples are always ran. I've removed the output requirement and the examples no longer run. wg0 is now used.

Before, I used the global state to split the examples for New() and Client methods. Basically to make the compile work. In the latest commit I've merged the New() and client.ConfigureDevice() into one example Also doing proper error checks now. The client.Device() example is also dropped, as the logic is the check os.IsNotExist(err), which is already shown in client.ConfigureDevice(). This way i could drop the global state for client.

The wgtypes example is now condensed to a single example to show generation of a Private key and Public key from it.

Hope this is better :)

muhlemmer avatar Mar 27 '20 16:03 muhlemmer

Being new to the library I do appreciate the example, thank you! Helped me get going after being stuck for quite some time.

th3wingman avatar Nov 18 '22 21:11 th3wingman