-

   rss_rss_hh_new

 - e-mail

 

 -

 LiveInternet.ru:
: 17.03.2011
:
:
: 51

:


[ ] Go PowerShell

, 02 2017 . 14:52 +
PowerShell

! Go, - Package Manager . , . Go . , , PowerShell, 3, - ( , ). , . , PowerShell, . , .

, PS. :

Wikipedia
Windows PowerShell Microsoft , .

. , . Microsoft , , ;). . PowerShell, :

PowerShell

:

Set-ExecutionPolicy RemoteSigned

, , , Y.
PowerShell . :

<>-<>

, , . Alias , CMD, Bash. , . Clear-Host, : cls clear. Get-Alias.

, PowerShell . PowerShell *.ps1. :

New-Item -Path 'C:\work\goPS.ps1' -Type File -Force

-Path , . -Type , , . -Force , .

: Go? : Go-Search, , API. .

, PowerShell ISE, . :

function Find-GoPackage {
    
}

. PS , Bash CMD , , . , . PS PHP $my_var. , .

# 
$no_type
# , 
[string]$have_type

:

[CmdletBinding()]
Param (
    [string]$Name = ""
)

, , .

. . , , , Invoke-WebRequest, .

:

$uri = "http://go-search.org/api?action=search&q=" + $Name

PowerShell . json, , . PS . ConvertFrom-Json Json json. , , .

$hits = $($(Invoke-WebRequest -Uri $uri).Content | ConvertFrom-Json).hits

, .Content ( |) ConvertFrom-JSON. , , .hits, . !

, :

return $hits

:

function Find-GoPackage {
    [CmdletBinding()]
    Param (
        [string]$Name = ""
    )

    $uri = "http://go-search.org/api?action=search&q=" + $Name
    $hits = $($(Invoke-WebRequest -Uri $uri).Content | ConvertFrom-Json).hits
    return $hits
}

PowerShell :

PS C:\ >. C:\work\goPS.ps1

PowerShell .

, , Find-GoPackage -Name json json, :

Find-GoPackage json | Format-Table -Wrap -AutoSize

.

, : PS . , , .

PS :

Test-Path $PROFILE

$PROFILE , . $false, . :

New-Item -Path $PROFILE -Type File -Force

:

notepad $PROFILE

, , PowerShell , .

, !
Original source: habrahabr.ru (comments, light).

https://habrahabr.ru/post/334720/

:  

: [1] []
 

:
: 

: ( )

:

  URL