-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve http/reader/writer; add net package; procs support vars
- Loading branch information
1 parent
d55c730
commit 72d2cd4
Showing
9 changed files
with
155 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package gexe | ||
|
||
import ( | ||
"github.com/vladimirvivien/gexe/net" | ||
) | ||
|
||
func (e *Echo) AddressUsable(addr string) error { | ||
return net.AddrUsable(e.Eval(addr)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package net | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"net" | ||
"os" | ||
"syscall" | ||
) | ||
|
||
func AddrUsable(address string) error { | ||
addr, err := net.ResolveTCPAddr("tcp", address) | ||
if err != nil { | ||
return fmt.Errorf("net: address parsing: %s", err) | ||
} | ||
|
||
lsnr, err := net.Listen(addr.Network(), addr.String()) | ||
|
||
if err != nil { | ||
sysErr, ok := err.(*os.SyscallError) | ||
if ok && errors.Is(sysErr.Err, syscall.EADDRINUSE) { | ||
return fmt.Errorf("net: addr in use: %s", sysErr.Err) | ||
} | ||
return fmt.Errorf("net: %s", err) | ||
} | ||
|
||
defer lsnr.Close() | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters